local device = {} device.model = "TS0601_water_switch" device.vendor = "Tuya" device.description = "Dual water valve" device.exposes = { { type = "enum", name = "valve_status", property = "valve_status_l1", access = 1, description = "Valve 1 status (manual, auto, idle)", endpoint = "l1", values = { "manual", "auto", "idle" }, }, { type = "enum", name = "valve_status", property = "valve_status_l2", access = 1, description = "Valve 2 status (manual, auto, idle)", endpoint = "l2", values = { "manual", "auto", "idle" }, }, { type = "switch", description = "Valve 1 on/off", endpoint = "l1", features = { { type = "binary", name = "state", property = "state_l1", access = 7, value_on = "ON", value_off = "OFF", description = "On/off state of the switch", endpoint = "l1", }, }, }, { type = "switch", description = "Valve 2 on/off", endpoint = "l2", features = { { type = "binary", name = "state", property = "state_l2", access = 7, value_on = "ON", value_off = "OFF", description = "On/off state of the switch", endpoint = "l2", }, }, }, { type = "numeric", name = "countdown", property = "countdown_l1", access = 3, unit = "min", min = 0, max = 1440, description = "Valve 1 countdown in minutes", endpoint = "l1", }, { type = "numeric", name = "countdown", property = "countdown_l2", access = 3, unit = "min", min = 0, max = 1440, description = "Valve 2 countdown in minutes", endpoint = "l2", }, { type = "numeric", name = "valve_duration", property = "valve_duration_l1", access = 1, unit = "s", description = "Valve 1 irrigation last duration in seconds", endpoint = "l1", }, { type = "numeric", name = "valve_duration", property = "valve_duration_l2", access = 1, unit = "s", description = "Valve 2 irrigation last duration in seconds", endpoint = "l2", }, { type = "numeric", name = "battery", property = "battery", access = 1, unit = "%", min = 0, max = 100, description = "Remaining battery in %, can take up to 24 hours before reported", category = "diagnostic", }, } device.fromZigbee = { "battery" } device.tuyaDatapoints = { { dp = 1, name = "state_l1", converter = "onOff" }, { dp = 2, name = "state_l2", converter = "onOff" }, { dp = 13, name = "countdown_l1", converter = "raw" }, { dp = 14, name = "countdown_l2", converter = "raw" }, { dp = 25, name = "valve_duration_l1", converter = "raw" }, { dp = 26, name = "valve_duration_l2", converter = "raw" }, { dp = 104, name = "valve_status_l1", converter = "lookup", lookup = { manual = 0, auto = 1, idle = 2 } }, { dp = 105, name = "valve_status_l2", converter = "lookup", lookup = { manual = 0, auto = 1, idle = 2 } }, { dp = 59, name = "battery", converter = "raw" }, } device.configure = { bind = { "genPowerCfg" }, reporting = { { cluster = "genPowerCfg", attribute = "batteryPercentageRemaining", min = 3600, max = 65000, change = 0, }, { cluster = "genPowerCfg", attribute = "batteryVoltage", min = 3600, max = 65000, change = 0, }, }, } device.meta = { multiEndpoint = true } device.fingerprint = { { model = "TS0601", manufacturer = "_TZE284_eaet5qt5", }, { model = "TS0601", manufacturer = "_TZE284_fhvpaltk", }, } return device