local device = {} device.model = "TS0601_din_4" device.vendor = "Tuya" device.description = "Din rail switch with power monitoring and threshold settings" device.exposes = { { type = "switch", features = { { type = "binary", name = "state", property = "state", access = 3, value_on = "ON", value_off = "OFF", description = "On/off state of the switch", }, }, }, { type = "numeric", name = "power", property = "power", access = 1, unit = "W", description = "Instantaneous measured power", }, { type = "numeric", name = "current", property = "current", access = 1, unit = "A", description = "Instantaneous measured electrical current", }, { type = "numeric", name = "voltage", property = "voltage", access = 1, unit = "V", description = "Measured electrical potential value", }, { type = "numeric", name = "energy", property = "energy", access = 1, unit = "kWh", description = "Sum of consumed energy", }, { type = "numeric", name = "temperature", property = "temperature", access = 1, unit = "°C", description = "Current temperature", }, { type = "numeric", name = "leakage", property = "leakage", access = 1, unit = "mA", description = "Current leakage", }, } device.fromZigbee = { "electrical", "metering", "temperature" } device.tuyaDatapoints = { { dp = 16, name = "state", converter = "onOff" }, { dp = 1, name = "energy", converter = "divideBy100" }, { dp = 15, name = "leakage", converter = "raw" }, { dp = 103, name = "temperature", converter = "raw" }, } device.configure = { bind = { "haElectricalMeasurement", "seMetering", "msTemperatureMeasurement" }, 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, }, { cluster = "seMetering", attribute = "currentSummDelivered", min = 5, max = 3600, change = 1, }, { cluster = "msTemperatureMeasurement", attribute = "measuredValue", min = 10, max = 3600, change = 100, }, }, } device.fingerprint = { { model = "TS0601", manufacturer = "_TZE204_fhvdgeuh", }, { model = "TS0601", manufacturer = "_TZE200_abatw3kj", }, { model = "TS0601", manufacturer = "_TZE204_4bjixefp", }, } return device