local device = {} device.model = "LYAI-14" device.vendor = "Tuya" device.description = "Solar intelligent timed water valve controller" device.exposes = { { type = "numeric", name = "countdown", property = "countdown", access = 7, unit = "s", min = 0, max = 43200, value_step = 1, description = "Countdown to turn device off after a certain time", }, { type = "numeric", name = "error_status", property = "error_status", access = 1, description = "Device error code", }, { type = "enum", name = "rain_sensor_status", property = "rain_sensor_status", access = 1, description = "Rain sensor state", values = { "rain", "no_rain" }, }, { type = "binary", name = "rain_sensor_switch", property = "rain_sensor_switch", access = 3, value_on = "ON", value_off = "OFF", description = "Enable/disable rain sensor", }, { type = "enum", name = "battery_state", property = "battery_state", access = 1, description = "Battery charging state", values = { "no_charge", "charging", "charged" }, }, { type = "numeric", name = "battery", property = "battery", access = 5, unit = "%", min = 0, max = 100, description = "Remaining battery in %", category = "diagnostic", }, { type = "switch", features = { { type = "binary", name = "state", property = "state", access = 7, value_on = "ON", value_off = "OFF", description = "On/off state of the switch", }, }, }, } device.fromZigbee = { "battery", "on_off" } device.tuyaDatapoints = { { dp = 1, name = "state", converter = "onOff" }, { dp = 4, name = "error_status", converter = "raw" }, { dp = 11, name = "countdown", converter = "countdown" }, { dp = 101, name = "rain_sensor_status", converter = "lookup", lookup = { rain = 0, no_rain = 1 } }, { dp = 102, name = "rain_sensor_switch", converter = "onOff" }, { dp = 103, name = "battery_state", converter = "lookup", lookup = { no_charge = 0, charging = 1, charged = 2 } }, } device.toZigbee = { "on_off" } device.configure = { bind = { "genPowerCfg", "genOnOff" }, reporting = { { cluster = "genPowerCfg", attribute = "batteryPercentageRemaining", min = 3600, max = 65000, change = 0, }, { cluster = "genPowerCfg", attribute = "batteryVoltage", min = 3600, max = 65000, change = 0, }, { cluster = "genOnOff", attribute = "onOff", min = 0, max = 3600, change = 0, }, }, } device.fingerprint = { { model = "TS0049", manufacturer = "_TZ3290_ixd9mvv4", }, } return device