local device = {} device.model = "2CT" 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", property = "power", access = 1, unit = "W", description = "Instantaneous measured power", }, { 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 = "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 = "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 = "update_frequency", property = "update_frequency", access = 3, unit = "s", min = 3, max = 60, description = "Update frequency", }, { type = "numeric", name = "timestamp_a", property = "timestamp_a", access = 1, description = "Timestamp at power measure (phase a)", }, { type = "numeric", name = "timestamp_b", property = "timestamp_b", access = 1, description = "Timestamp at power measure (phase b)", }, { type = "numeric", name = "calibration_ac_frequency", property = "calibration_ac_frequency", access = 3, min = 0.5, max = 1.5, value_step = 0.01, description = "Calibration AC frequency", }, { type = "numeric", name = "calibration_voltage", property = "calibration_voltage", access = 3, min = 0.5, max = 1.5, value_step = 0.01, description = "Calibration voltage", }, { type = "numeric", name = "calibration_power_a", property = "calibration_power_a", access = 3, min = 0.5, max = 1.5, value_step = 0.01, description = "Calibration power A", }, { type = "numeric", name = "calibration_current_a", property = "calibration_current_a", access = 3, min = 0.5, max = 1.5, value_step = 0.01, description = "Calibration current A", }, { type = "numeric", name = "calibration_power_b", property = "calibration_power_b", access = 3, min = 0.5, max = 1.5, value_step = 0.01, description = "Calibration power B", }, { type = "numeric", name = "calibration_current_b", property = "calibration_current_b", access = 3, min = 0.5, max = 1.5, value_step = 0.01, description = "Calibration current B", }, } device.fromZigbee = { "electrical" } device.tuyaDatapoints = { { dp = 105, name = "ac_frequency", converter = "divideBy100" }, { dp = 103, name = "power_a", converter = "divideBy10" }, { dp = 104, name = "power_b", converter = "divideBy10" }, { dp = 19, name = "power", converter = "divideBy10" }, { dp = 20, name = "voltage", converter = "divideBy10" }, { dp = 101, name = "current_a", converter = "divideBy1000" }, { dp = 102, name = "current_b", converter = "divideBy1000" }, { dp = 120, name = "power_factor_a", converter = "raw" }, { dp = 121, name = "power_factor_b", converter = "raw" }, { dp = 115, name = "energy_a", converter = "divideBy100" }, { dp = 117, name = "energy_b", converter = "divideBy100" }, { dp = 122, name = "update_frequency", converter = "raw" }, { dp = 123, name = "calibration_voltage", converter = "divideBy1000" }, { dp = 125, name = "calibration_current_a", converter = "divideBy1000" }, { dp = 126, name = "calibration_power_a", converter = "divideBy1000" }, { dp = 130, name = "calibration_current_b", converter = "divideBy1000" }, { dp = 131, name = "calibration_power_b", converter = "divideBy1000" }, { dp = 124, name = "calibration_ac_frequency", converter = "divideBy1000" }, } 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_dhotiauw", }, } return device