local device = {} device.model = "TS0601_dimmer_1_gang_3" device.vendor = "Tuya" device.description = "1 gang smart dimmer" device.exposes = { { type = "light", features = { { type = "binary", name = "state", property = "state", access = 3, value_on = "ON", value_off = "OFF", description = "On/off state of this light", }, { type = "numeric", name = "brightness", property = "brightness", access = 3, min = 0, max = 254, description = "Brightness of this light", }, }, }, { type = "numeric", name = "voltage", property = "voltage", access = 1, unit = "V", description = "Measured electrical potential value", }, { 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 = "binary", name = "child_lock", property = "child_lock", access = 3, value_on = "LOCK", value_off = "UNLOCK", description = "Enables/disables physical input on the device", }, { type = "binary", name = "backlight_mode", property = "backlight_mode", access = 7, value_on = "ON", value_off = "OFF", description = "Mode of the backlight", category = "config", }, } device.fromZigbee = { "electrical" } device.tuyaDatapoints = { { dp = 16, name = "backlight_mode", converter = "onOff" }, { dp = 21, name = "current", converter = "divideBy1000" }, { dp = 22, name = "power", converter = "divideBy10" }, { dp = 23, name = "voltage", converter = "divideBy10" }, { dp = 101, name = "child_lock", converter = "lockUnlock" }, { dp = 141, name = "state", converter = "onOff" }, { dp = 142, name = "brightness", converter = "scale0_254to0_1000" }, } 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.fingerprint = { { model = "TS0601", manufacturer = "_TZE200_qzaing2g", }, } return device