local device = {} device.model = "PJ-1203A" device.vendor = "Tuya" device.description = "Bidirectional energy meter with 80A current clamp" device.exposes = { { type = "numeric", name = "ac_frequency", property = "ac_frequency", access = 1, unit = "Hz", description = "Measured electrical AC frequency", }, { type = "numeric", name = "voltage", property = "voltage", access = 1, unit = "V", description = "Measured electrical potential value", }, { 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_ab", property = "power_ab", access = 1, unit = "W", description = "Instantaneous measured power (phase AB)", }, { 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 = "power_factor_a", property = "power_factor_a", access = 1, unit = "%", description = "Instantaneous measured power factor (phase A)", }, { type = "numeric", name = "power_factor_b", property = "power_factor_b", access = 1, unit = "%", description = "Instantaneous measured power factor (phase B)", }, { type = "enum", name = "energy_flow_a", property = "energy_flow_a", access = 1, description = "Direction of energy (phase A)", values = { "consuming", "producing", "sign" }, }, { type = "enum", name = "energy_flow_b", property = "energy_flow_b", access = 1, description = "Direction of energy (phase B)", values = { "consuming", "producing", "sign" }, }, { type = "numeric", name = "energy_a", property = "energy_a", access = 1, unit = "kWh", description = "Sum of consumed energy (phase A)", }, { type = "numeric", name = "energy_b", property = "energy_b", access = 1, unit = "kWh", description = "Sum of consumed energy (phase B)", }, { type = "numeric", name = "energy_produced_a", property = "energy_produced_a", access = 1, unit = "kWh", description = "Sum of produced energy (phase A)", }, { type = "numeric", name = "energy_produced_b", property = "energy_produced_b", access = 1, unit = "kWh", description = "Sum of produced energy (phase B)", }, { type = "numeric", name = "update_frequency", property = "update_frequency", access = 3, unit = "s", min = 3, max = 60, description = "Update frequency", }, { type = "text", name = "timestamp_a", property = "timestamp_a", access = 1, description = "Timestamp at power measure (phase a)", }, { type = "text", name = "timestamp_b", property = "timestamp_b", access = 1, description = "Timestamp at power measure (phase b)", }, } device.fromZigbee = { "electrical" } device.tuyaDatapoints = { { dp = 111, name = "ac_frequency", converter = "divideBy100" }, { dp = 112, name = "voltage", converter = "divideBy10" }, { dp = 129, name = "update_frequency", converter = "raw" }, } 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 = "_TZE204_81yrt3lo", }, { model = "TS0601", manufacturer = "_TZE284_81yrt3lo", }, } return device