local device = {} device.model = "DS-1450WN" device.vendor = "Tuya" device.description = "Smart Zigbee Switch with power monitoring" device.exposes = { { type = "switch", endpoint = "usb_a", features = { { type = "binary", name = "state", property = "state_usb_a", access = 7, value_on = "ON", value_off = "OFF", description = "On/off state of the switch", endpoint = "usb_a", }, }, }, { type = "switch", endpoint = "usb_c", features = { { type = "binary", name = "state", property = "state_usb_c", access = 7, value_on = "ON", value_off = "OFF", description = "On/off state of the switch", endpoint = "usb_c", }, }, }, { type = "switch", endpoint = "plug_1", features = { { type = "binary", name = "state", property = "state_plug_1", access = 7, value_on = "ON", value_off = "OFF", description = "On/off state of the switch", endpoint = "plug_1", }, }, }, { type = "switch", endpoint = "plug_2", features = { { type = "binary", name = "state", property = "state_plug_2", access = 7, value_on = "ON", value_off = "OFF", description = "On/off state of the switch", endpoint = "plug_2", }, }, }, { type = "numeric", name = "countdown_usb_a", property = "countdown_usb_a", access = 3, unit = "s", min = 0, max = 86400, value_step = 1, description = "Countdown timer for USB A", }, { type = "numeric", name = "countdown_usb_c", property = "countdown_usb_c", access = 3, unit = "s", min = 0, max = 86400, value_step = 1, description = "Countdown timer for USB C", }, { type = "numeric", name = "countdown_plug_1", property = "countdown_plug_1", access = 3, unit = "s", min = 0, max = 86400, value_step = 1, description = "Countdown timer for Plug 1", }, { type = "numeric", name = "countdown_plug_2", property = "countdown_plug_2", access = 3, unit = "s", min = 0, max = 86400, value_step = 1, description = "Countdown timer for Plug 2", }, { type = "enum", name = "relay_status", property = "relay_status", access = 3, description = "Set the Relay Status", values = { "memory", "on", "off" }, }, { type = "binary", name = "switch_backlight", property = "switch_backlight", access = 3, value_on = "ON", value_off = "OFF", description = "Enables/disables backlight indicator", }, { type = "numeric", name = "current", property = "current", access = 1, unit = "A", description = "Instantaneous measured electrical current", }, { type = "numeric", name = "power", property = "power", access = 1, unit = "W", description = "Instantaneous measured power", }, { type = "numeric", name = "voltage", property = "voltage", access = 1, unit = "V", description = "Measured electrical potential value", }, { type = "numeric", name = "produced_energy", property = "produced_energy", access = 1, unit = "kWh", description = "Sum of produced energy", }, { type = "binary", name = "child_lock", property = "child_lock", access = 3, value_on = "LOCK", value_off = "UNLOCK", description = "Enables/disables physical input on the device", }, } device.fromZigbee = { "electrical" } device.tuyaDatapoints = { { dp = 1, name = "state_usb_a", converter = "onOff" }, { dp = 2, name = "state_usb_c", converter = "onOff" }, { dp = 3, name = "state_plug_1", converter = "onOff" }, { dp = 4, name = "state_plug_2", converter = "onOff" }, { dp = 7, name = "countdown_usb_a", converter = "countdown" }, { dp = 8, name = "countdown_usb_c", converter = "countdown" }, { dp = 9, name = "countdown_plug_1", converter = "countdown" }, { dp = 10, name = "countdown_plug_2", converter = "countdown" }, { dp = 14, name = "relay_status", converter = "lookup", lookup = { memory = 0, on = 1, off = 2 } }, { dp = 16, name = "switch_backlight", converter = "onOff" }, { dp = 21, name = "current", converter = "divideBy10" }, { dp = 22, name = "power", converter = "divideBy10" }, { dp = 23, name = "voltage", converter = "divideBy10" }, { dp = 105, name = "produced_energy", converter = "divideBy10" }, { dp = 106, name = "child_lock", converter = "lockUnlock" }, } device.configure = { bind = { "haElectricalMeasurement" }, reporting = { { cluster = "haElectricalMeasurement", attribute = "activePower", min = 5, max = 3600, change = 1, }, { cluster = "haElectricalMeasurement", attribute = "rmsVoltage", min = 5, max = 3600, change = 5, }, { cluster = "haElectricalMeasurement", attribute = "rmsCurrent", min = 5, max = 3600, change = 100, }, }, } device.meta = { multiEndpoint = true } device.fingerprint = { { model = "TS0601", manufacturer = "_TZE204_mvtclclq", }, { model = "TS0601", manufacturer = "_TZE284_mvtclclq", }, } return device