local device = {} device.model = "TS0601_3_phase_clamp_meter_relay" device.vendor = "Tuya" device.description = "3-phase clamp power meter with relay" 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 = "energy", property = "energy", access = 1, unit = "kWh", description = "Sum of consumed energy", }, { type = "numeric", name = "produced_energy", property = "produced_energy", access = 1, unit = "kWh", description = "Sum of produced energy", }, { type = "numeric", name = "voltage_a", property = "voltage_a", access = 1, unit = "V", description = "Measured electrical potential value (phase A)", }, { type = "numeric", name = "voltage_b", property = "voltage_b", access = 1, unit = "V", description = "Measured electrical potential value (phase B)", }, { type = "numeric", name = "voltage_c", property = "voltage_c", access = 1, unit = "V", description = "Measured electrical potential value (phase C)", }, { type = "numeric", name = "power_a", property = "power_a", access = 1, unit = "W", description = "Instantaneous measured power (phase A)", }, { type = "numeric", name = "power_b", property = "power_b", access = 1, unit = "W", description = "Instantaneous measured power (phase B)", }, { type = "numeric", name = "power_c", property = "power_c", access = 1, unit = "W", description = "Instantaneous measured power (phase C)", }, { type = "numeric", name = "current_a", property = "current_a", access = 1, unit = "A", description = "Instantaneous measured electrical current (phase A)", }, { type = "numeric", name = "current_b", property = "current_b", access = 1, unit = "A", description = "Instantaneous measured electrical current (phase B)", }, { type = "numeric", name = "current_c", property = "current_c", access = 1, unit = "A", description = "Instantaneous measured electrical current (phase C)", }, } device.fromZigbee = { "electrical", "metering" } device.tuyaDatapoints = { { dp = 16, name = "state", converter = "onOff" }, { dp = 1, name = "energy", converter = "divideBy100" }, { dp = 2, name = "produced_energy", converter = "divideBy100" }, { dp = 9, name = "power", converter = "power" }, } 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, }, }, } device.fingerprint = { { model = "TS0601", manufacturer = "_TZE200_x8fp01wi", }, { model = "TS0601", manufacturer = "_TZE204_x8fp01wi", }, } return device