local device = {} device.model = "TS0601_din" device.vendor = "Tuya" device.description = "Zigbee smart energy meter DDS238-2 Zigbee" device.fingerprint = { { model = "TS0601", manufacturer = "_TZE200_byzdayie", }, { model = "TS0601", manufacturer = "_TZE200_fsb6zw01", }, { model = "TS0601", manufacturer = "_TZE200_ewxhg6o9", }, } 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 = "voltage", property = "voltage", access = 1, unit = "V", description = "Measured electrical potential value", }, { 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 = "energy", property = "energy", access = 1, unit = "kWh", description = "Sum of consumed energy", }, } device.fromZigbee = { "electrical", "metering" } device.tuyaDatapoints = { { dp = 1, name = "state", converter = "onOff" }, { dp = 17, name = "energy", converter = "divideBy100" }, { dp = 18, name = "current", converter = "divideBy1000" }, { dp = 19, name = "power", converter = "divideBy10" }, { dp = 20, name = "voltage", converter = "divideBy10" }, } device.configure = { bind = { "haElectricalMeasurement", "seMetering" }, 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, }, }, } return device