From 55d94e93d7c563f4320a5dd80aa5fc37934e7ffe Mon Sep 17 00:00:00 2001 From: dams74 Date: Tue, 29 Aug 2023 12:35:57 +0200 Subject: [PATCH 01/15] Update tuya.ts Update with new device https://github.com/Koenkk/zigbee2mqtt/issues/18419 --- src/devices/tuya.ts | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/devices/tuya.ts b/src/devices/tuya.ts index ba3d26429e26b..292f2bba857e6 100644 --- a/src/devices/tuya.ts +++ b/src/devices/tuya.ts @@ -5913,5 +5913,38 @@ const definitions: Definition[] = [ }, }, ]; - +const definition = { +fingerprint: [ +{ +modelID: 'TS0601', +manufacturerName: '_TZE204_81yrt3lo', +}, +], +model: 'TS0601_Bidirectional_Energy_Meter_with_80A_Current_Clamp', +vendor: 'TuYa', +description: 'Bidirectional Energy Meter with 80A Current Clamp', +fromZigbee: [tuya.fz.datapoints], +toZigbee: [tuya.tz.datapoints], +onEvent: tuya.onEventSetTime, +configure: tuya.configureMagicPacket, +whiteLabel: [ tuya.whitelabel('Tuya', 'PJ-1203A', 'Bidirectional Energy Meter with 80A Current Clamp', ['_TZE204_81yrt3lo']), ], +// whiteLabel: [{vendor: 'MatSeePlus', model: 'PJ-1203A'}], +exposes: [ //only report data +e.ac_frequency(), +exposes.numeric('total_power_A', ea.STATE).withUnit('W').withDescription('Total power A'), +exposes.numeric('total_power_B', ea.STATE).withUnit('W').withDescription('Total power B'), +exposes.numeric('total_power_AB', ea.STATE).withUnit('W').withDescription('Total power A'), +exposes.numeric('voltage', ea.STATE).withUnit('V').withDescription('Voltage'), +exposes.numeric('current_A', ea.STATE).withUnit('A').withDescription('Current A'), +exposes.numeric('current_B', ea.STATE).withUnit('A').withDescription('Current B'), +exposes.numeric('power_factor_A', ea.STATE).withUnit('%').withDescription('Instantaneous measured power factor A'), +exposes.numeric('power_factor_B', ea.STATE).withUnit('%').withDescription('Instantaneous measured power factor B'), +exposes.numeric('power_direction A', ea.STATE).withDescription('Power direction A 0/1 for forward/reverse'), +exposes.numeric('power_direction B', ea.STATE).withDescription('Power direction B 0/1 for forward/reverse'), +exposes.numeric('energy_forward_A', ea.STATE).withUnit('kWh').withDescription('Total energy A forward'), +exposes.numeric('energy_forward_B', ea.STATE).withUnit('kWh').withDescription('Total energy B forward'), +exposes.numeric('energy_reverse_A', ea.STATE).withUnit('kWh').withDescription('Total energy A reverse'), +exposes.numeric('energy_reverse_B', ea.STATE).withUnit('kWh').withDescription('Total energy B reverse'), +exposes.numeric('update_frequency', ea.STATE).withUnit('sec').withDescription('Update frequency'), +], module.exports = definitions; From 76ed4f6fd266c4e02536904b97f783acc92be3ed Mon Sep 17 00:00:00 2001 From: dams74 Date: Tue, 29 Aug 2023 13:37:41 +0200 Subject: [PATCH 02/15] Update tuya.ts --- src/devices/tuya.ts | 55 ++++++++++++++++++--------------------------- 1 file changed, 22 insertions(+), 33 deletions(-) diff --git a/src/devices/tuya.ts b/src/devices/tuya.ts index 292f2bba857e6..0fa0531ce66cd 100644 --- a/src/devices/tuya.ts +++ b/src/devices/tuya.ts @@ -5913,38 +5913,27 @@ const definitions: Definition[] = [ }, }, ]; -const definition = { -fingerprint: [ -{ -modelID: 'TS0601', -manufacturerName: '_TZE204_81yrt3lo', +const definition = { fingerprint: [ { modelID: 'TS0601', manufacturerName: '_TZE204_81yrt3lo', }, ], model: 'TS0601_Bidirectional_Energy_Meter_with_80A_Current_Clamp', vendor: 'TuYa', description: 'Bidirectional Energy Meter with 80A Current Clamp', fromZigbee: [tuya.fz.datapoints], toZigbee: [tuya.tz.datapoints], onEvent: tuya.onEventSetTime, configure: tuya.configureMagicPacket, whiteLabel: [ tuya.whitelabel('Tuya', 'PJ-1203A', 'Bidirectional Energy Meter with 80A Current Clamp', ['_TZE204_81yrt3lo']), ], // whiteLabel: [{vendor: 'MatSeePlus', model: 'PJ-1203A'}], exposes: [ //only report data e.ac_frequency(), exposes.numeric('total_power_A', ea.STATE).withUnit('W').withDescription('Total power A'), exposes.numeric('total_power_B', ea.STATE).withUnit('W').withDescription('Total power B'), exposes.numeric('total_power_AB', ea.STATE).withUnit('W').withDescription('Total power A'), exposes.numeric('voltage', ea.STATE).withUnit('V').withDescription('Voltage'), exposes.numeric('current_A', ea.STATE).withUnit('A').withDescription('Current A'), exposes.numeric('current_B', ea.STATE).withUnit('A').withDescription('Current B'), exposes.numeric('power_factor_A', ea.STATE).withUnit('%').withDescription('Instantaneous measured power factor A'), exposes.numeric('power_factor_B', ea.STATE).withUnit('%').withDescription('Instantaneous measured power factor B'), exposes.numeric('power_direction A', ea.STATE).withDescription('Power direction A 0/1 for forward/reverse'), exposes.numeric('power_direction B', ea.STATE).withDescription('Power direction B 0/1 for forward/reverse'), exposes.numeric('energy_forward_A', ea.STATE).withUnit('kWh').withDescription('Total energy A forward'), exposes.numeric('energy_forward_B', ea.STATE).withUnit('kWh').withDescription('Total energy B forward'), exposes.numeric('energy_reverse_A', ea.STATE).withUnit('kWh').withDescription('Total energy A reverse'), exposes.numeric('energy_reverse_B', ea.STATE).withUnit('kWh').withDescription('Total energy B reverse'), exposes.numeric('update_frequency', ea.STATE).withUnit('sec').withDescription('Update frequency'), ], + +meta: { + tuyaDatapoints: [//only report data + [111, 'ac_frequency', tuya.valueConverter.divideBy100], + [101, 'total_power_A', tuya.valueConverter.divideBy10], + [105, 'total_power_B', tuya.valueConverter.divideBy10], + [115, 'total_power_AB', tuya.valueConverter.divideBy10], + [112, 'voltage', tuya.valueConverter.divideBy10], + [113, 'current_A', tuya.valueConverter.divideBy1000], + [114, 'current_B', tuya.valueConverter.divideBy1000], + [110, 'power_factor_A', tuya.valueConverter.divideBy100], + [121, 'power_factor_B', tuya.valueConverter.divideBy100], + [102, 'power_direction A', tuya.valueConverter.raw], + [104, 'power_direction B', tuya.valueConverter.raw], + [106, 'energy_forward_A', tuya.valueConverter.divideBy100], + [108, 'energy_forward_B', tuya.valueConverter.divideBy100], + [107, 'energy_reverse_A', tuya.valueConverter.divideBy100], + [109, 'energy_reverse_B', tuya.valueConverter.divideBy100], + [129, 'update_frequency' , tuya.valueConverter.raw], + ], }, -], -model: 'TS0601_Bidirectional_Energy_Meter_with_80A_Current_Clamp', -vendor: 'TuYa', -description: 'Bidirectional Energy Meter with 80A Current Clamp', -fromZigbee: [tuya.fz.datapoints], -toZigbee: [tuya.tz.datapoints], -onEvent: tuya.onEventSetTime, -configure: tuya.configureMagicPacket, -whiteLabel: [ tuya.whitelabel('Tuya', 'PJ-1203A', 'Bidirectional Energy Meter with 80A Current Clamp', ['_TZE204_81yrt3lo']), ], -// whiteLabel: [{vendor: 'MatSeePlus', model: 'PJ-1203A'}], -exposes: [ //only report data -e.ac_frequency(), -exposes.numeric('total_power_A', ea.STATE).withUnit('W').withDescription('Total power A'), -exposes.numeric('total_power_B', ea.STATE).withUnit('W').withDescription('Total power B'), -exposes.numeric('total_power_AB', ea.STATE).withUnit('W').withDescription('Total power A'), -exposes.numeric('voltage', ea.STATE).withUnit('V').withDescription('Voltage'), -exposes.numeric('current_A', ea.STATE).withUnit('A').withDescription('Current A'), -exposes.numeric('current_B', ea.STATE).withUnit('A').withDescription('Current B'), -exposes.numeric('power_factor_A', ea.STATE).withUnit('%').withDescription('Instantaneous measured power factor A'), -exposes.numeric('power_factor_B', ea.STATE).withUnit('%').withDescription('Instantaneous measured power factor B'), -exposes.numeric('power_direction A', ea.STATE).withDescription('Power direction A 0/1 for forward/reverse'), -exposes.numeric('power_direction B', ea.STATE).withDescription('Power direction B 0/1 for forward/reverse'), -exposes.numeric('energy_forward_A', ea.STATE).withUnit('kWh').withDescription('Total energy A forward'), -exposes.numeric('energy_forward_B', ea.STATE).withUnit('kWh').withDescription('Total energy B forward'), -exposes.numeric('energy_reverse_A', ea.STATE).withUnit('kWh').withDescription('Total energy A reverse'), -exposes.numeric('energy_reverse_B', ea.STATE).withUnit('kWh').withDescription('Total energy B reverse'), -exposes.numeric('update_frequency', ea.STATE).withUnit('sec').withDescription('Update frequency'), -], +}; module.exports = definitions; From 53448bee23aa47b5720d1971ef1e7e7fefc04e6f Mon Sep 17 00:00:00 2001 From: dams74 Date: Tue, 29 Aug 2023 13:48:20 +0200 Subject: [PATCH 03/15] Update tuya.ts sorry an other update --- src/devices/tuya.ts | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/devices/tuya.ts b/src/devices/tuya.ts index 0fa0531ce66cd..cbdc3c405a752 100644 --- a/src/devices/tuya.ts +++ b/src/devices/tuya.ts @@ -12,7 +12,6 @@ import {ColorMode, colorModeLookup} from '../lib/constants'; import fz from '../converters/fromZigbee'; import tz from '../converters/toZigbee'; import {KeyValue, Definition, Tz, Fz, Expose, KeyValueAny, KeyValueNumberString, KeyValueString} from '../lib/types'; - const e = exposes.presets; const ea = exposes.access; @@ -5913,8 +5912,31 @@ const definitions: Definition[] = [ }, }, ]; -const definition = { fingerprint: [ { modelID: 'TS0601', manufacturerName: '_TZE204_81yrt3lo', }, ], model: 'TS0601_Bidirectional_Energy_Meter_with_80A_Current_Clamp', vendor: 'TuYa', description: 'Bidirectional Energy Meter with 80A Current Clamp', fromZigbee: [tuya.fz.datapoints], toZigbee: [tuya.tz.datapoints], onEvent: tuya.onEventSetTime, configure: tuya.configureMagicPacket, whiteLabel: [ tuya.whitelabel('Tuya', 'PJ-1203A', 'Bidirectional Energy Meter with 80A Current Clamp', ['_TZE204_81yrt3lo']), ], // whiteLabel: [{vendor: 'MatSeePlus', model: 'PJ-1203A'}], exposes: [ //only report data e.ac_frequency(), exposes.numeric('total_power_A', ea.STATE).withUnit('W').withDescription('Total power A'), exposes.numeric('total_power_B', ea.STATE).withUnit('W').withDescription('Total power B'), exposes.numeric('total_power_AB', ea.STATE).withUnit('W').withDescription('Total power A'), exposes.numeric('voltage', ea.STATE).withUnit('V').withDescription('Voltage'), exposes.numeric('current_A', ea.STATE).withUnit('A').withDescription('Current A'), exposes.numeric('current_B', ea.STATE).withUnit('A').withDescription('Current B'), exposes.numeric('power_factor_A', ea.STATE).withUnit('%').withDescription('Instantaneous measured power factor A'), exposes.numeric('power_factor_B', ea.STATE).withUnit('%').withDescription('Instantaneous measured power factor B'), exposes.numeric('power_direction A', ea.STATE).withDescription('Power direction A 0/1 for forward/reverse'), exposes.numeric('power_direction B', ea.STATE).withDescription('Power direction B 0/1 for forward/reverse'), exposes.numeric('energy_forward_A', ea.STATE).withUnit('kWh').withDescription('Total energy A forward'), exposes.numeric('energy_forward_B', ea.STATE).withUnit('kWh').withDescription('Total energy B forward'), exposes.numeric('energy_reverse_A', ea.STATE).withUnit('kWh').withDescription('Total energy A reverse'), exposes.numeric('energy_reverse_B', ea.STATE).withUnit('kWh').withDescription('Total energy B reverse'), exposes.numeric('update_frequency', ea.STATE).withUnit('sec').withDescription('Update frequency'), ], - +const definition = { fingerprint: [ { modelID: 'TS0601', manufacturerName: '_TZE204_81yrt3lo', }, ], + model: 'TS0601_Bidirectional_Energy_Meter_with_80A_Current_Clamp', + vendor: 'TuYa', description: 'Bidirectional Energy Meter with 80A Current Clamp', + fromZigbee: [tuya.fz.datapoints], + toZigbee: [tuya.tz.datapoints], + onEvent: tuya.onEventSetTime, + configure: tuya.configureMagicPacket, + whiteLabel: [ tuya.whitelabel('Tuya', 'PJ-1203A', 'Bidirectional Energy Meter with 80A Current Clamp', ['_TZE204_81yrt3lo']), ], // whiteLabel: [{vendor: 'MatSeePlus', model: 'PJ-1203A'}], + exposes: [ //only report data + e.ac_frequency(), + exposes.numeric('total_power_A', ea.STATE).withUnit('W').withDescription('Total power A'), + exposes.numeric('total_power_B', ea.STATE).withUnit('W').withDescription('Total power B'), + exposes.numeric('total_power_AB', ea.STATE).withUnit('W').withDescription('Total power A'), + exposes.numeric('voltage', ea.STATE).withUnit('V').withDescription('Voltage'), + exposes.numeric('current_A', ea.STATE).withUnit('A').withDescription('Current A'), + exposes.numeric('current_B', ea.STATE).withUnit('A').withDescription('Current B'), + exposes.numeric('power_factor_A', ea.STATE).withUnit('%').withDescription('Instantaneous measured power factor A'), + exposes.numeric('power_factor_B', ea.STATE).withUnit('%').withDescription('Instantaneous measured power factor B'), + exposes.numeric('power_direction A', ea.STATE).withDescription('Power direction A 0/1 for forward/reverse'), + exposes.numeric('power_direction B', ea.STATE).withDescription('Power direction B 0/1 for forward/reverse'), + exposes.numeric('energy_forward_A', ea.STATE).withUnit('kWh').withDescription('Total energy A forward'), + exposes.numeric('energy_forward_B', ea.STATE).withUnit('kWh').withDescription('Total energy B forward'), + exposes.numeric('energy_reverse_A', ea.STATE).withUnit('kWh').withDescription('Total energy A reverse'), + exposes.numeric('energy_reverse_B', ea.STATE).withUnit('kWh').withDescription('Total energy B reverse'), + exposes.numeric('update_frequency', ea.STATE).withUnit('sec').withDescription('Update frequency'), ], meta: { tuyaDatapoints: [//only report data [111, 'ac_frequency', tuya.valueConverter.divideBy100], From 2859b32604896aa6664a9d7bb062c6ea703249fb Mon Sep 17 00:00:00 2001 From: dams74 Date: Tue, 29 Aug 2023 13:52:43 +0200 Subject: [PATCH 04/15] Update tuya.ts other update --- src/devices/tuya.ts | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/devices/tuya.ts b/src/devices/tuya.ts index cbdc3c405a752..0bcafc6e3294d 100644 --- a/src/devices/tuya.ts +++ b/src/devices/tuya.ts @@ -5922,21 +5922,21 @@ const definition = { fingerprint: [ { modelID: 'TS0601', manufacturerName: '_TZE whiteLabel: [ tuya.whitelabel('Tuya', 'PJ-1203A', 'Bidirectional Energy Meter with 80A Current Clamp', ['_TZE204_81yrt3lo']), ], // whiteLabel: [{vendor: 'MatSeePlus', model: 'PJ-1203A'}], exposes: [ //only report data e.ac_frequency(), - exposes.numeric('total_power_A', ea.STATE).withUnit('W').withDescription('Total power A'), - exposes.numeric('total_power_B', ea.STATE).withUnit('W').withDescription('Total power B'), - exposes.numeric('total_power_AB', ea.STATE).withUnit('W').withDescription('Total power A'), - exposes.numeric('voltage', ea.STATE).withUnit('V').withDescription('Voltage'), - exposes.numeric('current_A', ea.STATE).withUnit('A').withDescription('Current A'), - exposes.numeric('current_B', ea.STATE).withUnit('A').withDescription('Current B'), - exposes.numeric('power_factor_A', ea.STATE).withUnit('%').withDescription('Instantaneous measured power factor A'), - exposes.numeric('power_factor_B', ea.STATE).withUnit('%').withDescription('Instantaneous measured power factor B'), - exposes.numeric('power_direction A', ea.STATE).withDescription('Power direction A 0/1 for forward/reverse'), - exposes.numeric('power_direction B', ea.STATE).withDescription('Power direction B 0/1 for forward/reverse'), - exposes.numeric('energy_forward_A', ea.STATE).withUnit('kWh').withDescription('Total energy A forward'), - exposes.numeric('energy_forward_B', ea.STATE).withUnit('kWh').withDescription('Total energy B forward'), - exposes.numeric('energy_reverse_A', ea.STATE).withUnit('kWh').withDescription('Total energy A reverse'), - exposes.numeric('energy_reverse_B', ea.STATE).withUnit('kWh').withDescription('Total energy B reverse'), - exposes.numeric('update_frequency', ea.STATE).withUnit('sec').withDescription('Update frequency'), ], + e.numeric('total_power_A', ea.STATE).withUnit('W').withDescription('Total power A'), + e.numeric('total_power_B', ea.STATE).withUnit('W').withDescription('Total power B'), + e.numeric('total_power_AB', ea.STATE).withUnit('W').withDescription('Total power A'), + e.numeric('voltage', ea.STATE).withUnit('V').withDescription('Voltage'), + e.numeric('current_A', ea.STATE).withUnit('A').withDescription('Current A'), + e.numeric('current_B', ea.STATE).withUnit('A').withDescription('Current B'), + e.numeric('power_factor_A', ea.STATE).withUnit('%').withDescription('Instantaneous measured power factor A'), + e.numeric('power_factor_B', ea.STATE).withUnit('%').withDescription('Instantaneous measured power factor B'), + e.numeric('power_direction A', ea.STATE).withDescription('Power direction A 0/1 for forward/reverse'), + e.numeric('power_direction B', ea.STATE).withDescription('Power direction B 0/1 for forward/reverse'), + e.numeric('energy_forward_A', ea.STATE).withUnit('kWh').withDescription('Total energy A forward'), + e.numeric('energy_forward_B', ea.STATE).withUnit('kWh').withDescription('Total energy B forward'), + e.numeric('energy_reverse_A', ea.STATE).withUnit('kWh').withDescription('Total energy A reverse'), + e.numeric('energy_reverse_B', ea.STATE).withUnit('kWh').withDescription('Total energy B reverse'), + e.numeric('update_frequency', ea.STATE).withUnit('sec').withDescription('Update frequency'), ], meta: { tuyaDatapoints: [//only report data [111, 'ac_frequency', tuya.valueConverter.divideBy100], From 4b5a4bc6f3b6a5a01cc206d90a2bbfb38069ecd5 Mon Sep 17 00:00:00 2001 From: dams74 Date: Tue, 29 Aug 2023 14:20:33 +0200 Subject: [PATCH 05/15] Update tuya.ts update --- src/devices/tuya.ts | 93 +++++++++++++++++++++++---------------------- 1 file changed, 48 insertions(+), 45 deletions(-) diff --git a/src/devices/tuya.ts b/src/devices/tuya.ts index 0bcafc6e3294d..5d5ff01634eda 100644 --- a/src/devices/tuya.ts +++ b/src/devices/tuya.ts @@ -5912,50 +5912,53 @@ const definitions: Definition[] = [ }, }, ]; -const definition = { fingerprint: [ { modelID: 'TS0601', manufacturerName: '_TZE204_81yrt3lo', }, ], - model: 'TS0601_Bidirectional_Energy_Meter_with_80A_Current_Clamp', - vendor: 'TuYa', description: 'Bidirectional Energy Meter with 80A Current Clamp', - fromZigbee: [tuya.fz.datapoints], - toZigbee: [tuya.tz.datapoints], - onEvent: tuya.onEventSetTime, - configure: tuya.configureMagicPacket, - whiteLabel: [ tuya.whitelabel('Tuya', 'PJ-1203A', 'Bidirectional Energy Meter with 80A Current Clamp', ['_TZE204_81yrt3lo']), ], // whiteLabel: [{vendor: 'MatSeePlus', model: 'PJ-1203A'}], - exposes: [ //only report data - e.ac_frequency(), - e.numeric('total_power_A', ea.STATE).withUnit('W').withDescription('Total power A'), - e.numeric('total_power_B', ea.STATE).withUnit('W').withDescription('Total power B'), - e.numeric('total_power_AB', ea.STATE).withUnit('W').withDescription('Total power A'), - e.numeric('voltage', ea.STATE).withUnit('V').withDescription('Voltage'), - e.numeric('current_A', ea.STATE).withUnit('A').withDescription('Current A'), - e.numeric('current_B', ea.STATE).withUnit('A').withDescription('Current B'), - e.numeric('power_factor_A', ea.STATE).withUnit('%').withDescription('Instantaneous measured power factor A'), - e.numeric('power_factor_B', ea.STATE).withUnit('%').withDescription('Instantaneous measured power factor B'), - e.numeric('power_direction A', ea.STATE).withDescription('Power direction A 0/1 for forward/reverse'), - e.numeric('power_direction B', ea.STATE).withDescription('Power direction B 0/1 for forward/reverse'), - e.numeric('energy_forward_A', ea.STATE).withUnit('kWh').withDescription('Total energy A forward'), - e.numeric('energy_forward_B', ea.STATE).withUnit('kWh').withDescription('Total energy B forward'), - e.numeric('energy_reverse_A', ea.STATE).withUnit('kWh').withDescription('Total energy A reverse'), - e.numeric('energy_reverse_B', ea.STATE).withUnit('kWh').withDescription('Total energy B reverse'), - e.numeric('update_frequency', ea.STATE).withUnit('sec').withDescription('Update frequency'), ], -meta: { - tuyaDatapoints: [//only report data - [111, 'ac_frequency', tuya.valueConverter.divideBy100], - [101, 'total_power_A', tuya.valueConverter.divideBy10], - [105, 'total_power_B', tuya.valueConverter.divideBy10], - [115, 'total_power_AB', tuya.valueConverter.divideBy10], - [112, 'voltage', tuya.valueConverter.divideBy10], - [113, 'current_A', tuya.valueConverter.divideBy1000], - [114, 'current_B', tuya.valueConverter.divideBy1000], - [110, 'power_factor_A', tuya.valueConverter.divideBy100], - [121, 'power_factor_B', tuya.valueConverter.divideBy100], - [102, 'power_direction A', tuya.valueConverter.raw], - [104, 'power_direction B', tuya.valueConverter.raw], - [106, 'energy_forward_A', tuya.valueConverter.divideBy100], - [108, 'energy_forward_B', tuya.valueConverter.divideBy100], - [107, 'energy_reverse_A', tuya.valueConverter.divideBy100], - [109, 'energy_reverse_B', tuya.valueConverter.divideBy100], - [129, 'update_frequency' , tuya.valueConverter.raw], - ], + { + fingerprint: tuya.fingerprint('TS0601', ['_TZE204_81yrt3lo']), + model: 'TS0601_Bidirectional_Energy_Meter_with_80A_Current_Clamp', + vendor: 'TuYa', + description: 'Bidirectional Energy Meter with 80A Current Clamp', + fromZigbee: [tuya.fz.datapoints], + toZigbee: [tuya.tz.datapoints], + onEvent: tuya.onEventSetTime, + configure: tuya.configureMagicPacket, + whiteLabel: [ + tuya.whitelabel('Tuya', 'PJ-1203A', 'Bidirectional Energy Meter with 80A Current Clamp', ['_TZE204_81yrt3lo']), ], // whiteLabel: [{vendor: 'MatSeePlus', model: 'PJ-1203A'}], + exposes: [ //only report data + e.ac_frequency(), + e.numeric('total_power_A', ea.STATE).withUnit('W').withDescription('Total power A'), + e.numeric('total_power_B', ea.STATE).withUnit('W').withDescription('Total power B'), + e.numeric('total_power_AB', ea.STATE).withUnit('W').withDescription('Total power A'), + e.numeric('voltage', ea.STATE).withUnit('V').withDescription('Voltage'), + e.numeric('current_A', ea.STATE).withUnit('A').withDescription('Current A'), + e.numeric('current_B', ea.STATE).withUnit('A').withDescription('Current B'), + e.numeric('power_factor_A', ea.STATE).withUnit('%').withDescription('Instantaneous measured power factor A'), + e.numeric('power_factor_B', ea.STATE).withUnit('%').withDescription('Instantaneous measured power factor B'), + e.numeric('power_direction A', ea.STATE).withDescription('Power direction A 0/1 for forward/reverse'), + e.numeric('power_direction B', ea.STATE).withDescription('Power direction B 0/1 for forward/reverse'), + e.numeric('energy_forward_A', ea.STATE).withUnit('kWh').withDescription('Total energy A forward'), + e.numeric('energy_forward_B', ea.STATE).withUnit('kWh').withDescription('Total energy B forward'), + e.numeric('energy_reverse_A', ea.STATE).withUnit('kWh').withDescription('Total energy A reverse'), + e.numeric('energy_reverse_B', ea.STATE).withUnit('kWh').withDescription('Total energy B reverse'), + e.numeric('update_frequency', ea.STATE).withUnit('sec').withDescription('Update frequency'), ], + ], + meta: { + tuyaDatapoints: [//only report data + [111, 'ac_frequency', tuya.valueConverter.divideBy100], + [101, 'total_power_A', tuya.valueConverter.divideBy10], + [105, 'total_power_B', tuya.valueConverter.divideBy10], + [115, 'total_power_AB', tuya.valueConverter.divideBy10], + [112, 'voltage', tuya.valueConverter.divideBy10], + [113, 'current_A', tuya.valueConverter.divideBy1000], + [114, 'current_B', tuya.valueConverter.divideBy1000], + [110, 'power_factor_A', tuya.valueConverter.divideBy100], + [121, 'power_factor_B', tuya.valueConverter.divideBy100], + [102, 'power_direction A', tuya.valueConverter.raw], + [104, 'power_direction B', tuya.valueConverter.raw], + [106, 'energy_forward_A', tuya.valueConverter.divideBy100], + [108, 'energy_forward_B', tuya.valueConverter.divideBy100], + [107, 'energy_reverse_A', tuya.valueConverter.divideBy100], + [109, 'energy_reverse_B', tuya.valueConverter.divideBy100], + [129, 'update_frequency' , tuya.valueConverter.raw], + }, }, -}; module.exports = definitions; From d5fd979fc8bcd6ae6f50115313845e7b35c84bdc Mon Sep 17 00:00:00 2001 From: dams74 Date: Tue, 29 Aug 2023 14:33:32 +0200 Subject: [PATCH 06/15] Update tuya.ts update --- src/devices/tuya.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/devices/tuya.ts b/src/devices/tuya.ts index 5d5ff01634eda..26e630f52cbe3 100644 --- a/src/devices/tuya.ts +++ b/src/devices/tuya.ts @@ -5911,7 +5911,6 @@ const definitions: Definition[] = [ ], }, }, -]; { fingerprint: tuya.fingerprint('TS0601', ['_TZE204_81yrt3lo']), model: 'TS0601_Bidirectional_Energy_Meter_with_80A_Current_Clamp', @@ -5959,6 +5958,8 @@ const definitions: Definition[] = [ [107, 'energy_reverse_A', tuya.valueConverter.divideBy100], [109, 'energy_reverse_B', tuya.valueConverter.divideBy100], [129, 'update_frequency' , tuya.valueConverter.raw], + }, }, -}, +]; + module.exports = definitions; From 344700d99483e717785715acda16f60d83113477 Mon Sep 17 00:00:00 2001 From: dams74 Date: Tue, 29 Aug 2023 14:35:39 +0200 Subject: [PATCH 07/15] Update tuya.ts update --- src/devices/tuya.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/devices/tuya.ts b/src/devices/tuya.ts index 26e630f52cbe3..5ec01ef1e7605 100644 --- a/src/devices/tuya.ts +++ b/src/devices/tuya.ts @@ -5961,5 +5961,5 @@ const definitions: Definition[] = [ }, }, ]; - + module.exports = definitions; From 31c51156fdf53fcba9721c316a09890fbb67c82e Mon Sep 17 00:00:00 2001 From: dams74 Date: Tue, 29 Aug 2023 14:41:17 +0200 Subject: [PATCH 08/15] Update tuya.ts update --- src/devices/tuya.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/devices/tuya.ts b/src/devices/tuya.ts index 5ec01ef1e7605..25c3236ebb1ae 100644 --- a/src/devices/tuya.ts +++ b/src/devices/tuya.ts @@ -5938,7 +5938,7 @@ const definitions: Definition[] = [ e.numeric('energy_forward_B', ea.STATE).withUnit('kWh').withDescription('Total energy B forward'), e.numeric('energy_reverse_A', ea.STATE).withUnit('kWh').withDescription('Total energy A reverse'), e.numeric('energy_reverse_B', ea.STATE).withUnit('kWh').withDescription('Total energy B reverse'), - e.numeric('update_frequency', ea.STATE).withUnit('sec').withDescription('Update frequency'), ], + e.numeric('update_frequency', ea.STATE).withUnit('sec').withDescription('Update frequency'), ], meta: { tuyaDatapoints: [//only report data From c6c4037d24b7dd400059b4f079a840456ecab0dc Mon Sep 17 00:00:00 2001 From: dams74 Date: Tue, 29 Aug 2023 14:45:19 +0200 Subject: [PATCH 09/15] Update tuya.ts --- src/devices/tuya.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/devices/tuya.ts b/src/devices/tuya.ts index 25c3236ebb1ae..34ba4af5ba204 100644 --- a/src/devices/tuya.ts +++ b/src/devices/tuya.ts @@ -5958,6 +5958,7 @@ const definitions: Definition[] = [ [107, 'energy_reverse_A', tuya.valueConverter.divideBy100], [109, 'energy_reverse_B', tuya.valueConverter.divideBy100], [129, 'update_frequency' , tuya.valueConverter.raw], + ], }, }, ]; From aabe412547be2d405eb698650f6f30ec740f3652 Mon Sep 17 00:00:00 2001 From: dams74 Date: Tue, 29 Aug 2023 14:53:58 +0200 Subject: [PATCH 10/15] Update tuya.ts --- src/devices/tuya.ts | 83 +++++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 41 deletions(-) diff --git a/src/devices/tuya.ts b/src/devices/tuya.ts index 34ba4af5ba204..d9834f291b96d 100644 --- a/src/devices/tuya.ts +++ b/src/devices/tuya.ts @@ -5913,51 +5913,52 @@ const definitions: Definition[] = [ }, { fingerprint: tuya.fingerprint('TS0601', ['_TZE204_81yrt3lo']), - model: 'TS0601_Bidirectional_Energy_Meter_with_80A_Current_Clamp', - vendor: 'TuYa', - description: 'Bidirectional Energy Meter with 80A Current Clamp', - fromZigbee: [tuya.fz.datapoints], - toZigbee: [tuya.tz.datapoints], - onEvent: tuya.onEventSetTime, - configure: tuya.configureMagicPacket, - whiteLabel: [ - tuya.whitelabel('Tuya', 'PJ-1203A', 'Bidirectional Energy Meter with 80A Current Clamp', ['_TZE204_81yrt3lo']), ], // whiteLabel: [{vendor: 'MatSeePlus', model: 'PJ-1203A'}], - exposes: [ //only report data + model: 'TS0601_Bidirectional_Energy_Meter_with_80A_Current_Clamp', + vendor: 'TuYa', + description: 'Bidirectional Energy Meter with 80A Current Clamp', + fromZigbee: [tuya.fz.datapoints], + toZigbee: [tuya.tz.datapoints], + onEvent: tuya.onEventSetTime, + configure: tuya.configureMagicPacket, + whiteLabel: [ + tuya.whitelabel('Tuya', 'PJ-1203A', 'Bidirectional Energy Meter with 80A Current Clamp', ['_TZE204_81yrt3lo']), + ], + exposes: [ //only report data e.ac_frequency(), - e.numeric('total_power_A', ea.STATE).withUnit('W').withDescription('Total power A'), - e.numeric('total_power_B', ea.STATE).withUnit('W').withDescription('Total power B'), - e.numeric('total_power_AB', ea.STATE).withUnit('W').withDescription('Total power A'), - e.numeric('voltage', ea.STATE).withUnit('V').withDescription('Voltage'), - e.numeric('current_A', ea.STATE).withUnit('A').withDescription('Current A'), - e.numeric('current_B', ea.STATE).withUnit('A').withDescription('Current B'), - e.numeric('power_factor_A', ea.STATE).withUnit('%').withDescription('Instantaneous measured power factor A'), - e.numeric('power_factor_B', ea.STATE).withUnit('%').withDescription('Instantaneous measured power factor B'), - e.numeric('power_direction A', ea.STATE).withDescription('Power direction A 0/1 for forward/reverse'), - e.numeric('power_direction B', ea.STATE).withDescription('Power direction B 0/1 for forward/reverse'), - e.numeric('energy_forward_A', ea.STATE).withUnit('kWh').withDescription('Total energy A forward'), - e.numeric('energy_forward_B', ea.STATE).withUnit('kWh').withDescription('Total energy B forward'), - e.numeric('energy_reverse_A', ea.STATE).withUnit('kWh').withDescription('Total energy A reverse'), - e.numeric('energy_reverse_B', ea.STATE).withUnit('kWh').withDescription('Total energy B reverse'), + e.numeric('total_power_A', ea.STATE).withUnit('W').withDescription('Total power A'), + e.numeric('total_power_B', ea.STATE).withUnit('W').withDescription('Total power B'), + e.numeric('total_power_AB', ea.STATE).withUnit('W').withDescription('Total power A'), + e.numeric('voltage', ea.STATE).withUnit('V').withDescription('Voltage'), + e.numeric('current_A', ea.STATE).withUnit('A').withDescription('Current A'), + e.numeric('current_B', ea.STATE).withUnit('A').withDescription('Current B'), + e.numeric('power_factor_A', ea.STATE).withUnit('%').withDescription('Instantaneous measured power factor A'), + e.numeric('power_factor_B', ea.STATE).withUnit('%').withDescription('Instantaneous measured power factor B'), + e.numeric('power_direction A', ea.STATE).withDescription('Power direction A 0/1 for forward/reverse'), + e.numeric('power_direction B', ea.STATE).withDescription('Power direction B 0/1 for forward/reverse'), + e.numeric('energy_forward_A', ea.STATE).withUnit('kWh').withDescription('Total energy A forward'), + e.numeric('energy_forward_B', ea.STATE).withUnit('kWh').withDescription('Total energy B forward'), + e.numeric('energy_reverse_A', ea.STATE).withUnit('kWh').withDescription('Total energy A reverse'), + e.numeric('energy_reverse_B', ea.STATE).withUnit('kWh').withDescription('Total energy B reverse'), e.numeric('update_frequency', ea.STATE).withUnit('sec').withDescription('Update frequency'), ], meta: { - tuyaDatapoints: [//only report data - [111, 'ac_frequency', tuya.valueConverter.divideBy100], - [101, 'total_power_A', tuya.valueConverter.divideBy10], - [105, 'total_power_B', tuya.valueConverter.divideBy10], - [115, 'total_power_AB', tuya.valueConverter.divideBy10], - [112, 'voltage', tuya.valueConverter.divideBy10], - [113, 'current_A', tuya.valueConverter.divideBy1000], - [114, 'current_B', tuya.valueConverter.divideBy1000], - [110, 'power_factor_A', tuya.valueConverter.divideBy100], - [121, 'power_factor_B', tuya.valueConverter.divideBy100], - [102, 'power_direction A', tuya.valueConverter.raw], - [104, 'power_direction B', tuya.valueConverter.raw], - [106, 'energy_forward_A', tuya.valueConverter.divideBy100], - [108, 'energy_forward_B', tuya.valueConverter.divideBy100], - [107, 'energy_reverse_A', tuya.valueConverter.divideBy100], - [109, 'energy_reverse_B', tuya.valueConverter.divideBy100], - [129, 'update_frequency' , tuya.valueConverter.raw], + tuyaDatapoints: [ + [111, 'ac_frequency', tuya.valueConverter.divideBy100], + [101, 'total_power_A', tuya.valueConverter.divideBy10], + [105, 'total_power_B', tuya.valueConverter.divideBy10], + [115, 'total_power_AB', tuya.valueConverter.divideBy10], + [112, 'voltage', tuya.valueConverter.divideBy10], + [113, 'current_A', tuya.valueConverter.divideBy1000], + [114, 'current_B', tuya.valueConverter.divideBy1000], + [110, 'power_factor_A', tuya.valueConverter.divideBy100], + [121, 'power_factor_B', tuya.valueConverter.divideBy100], + [102, 'power_direction A', tuya.valueConverter.raw], + [104, 'power_direction B', tuya.valueConverter.raw], + [106, 'energy_forward_A', tuya.valueConverter.divideBy100], + [108, 'energy_forward_B', tuya.valueConverter.divideBy100], + [107, 'energy_reverse_A', tuya.valueConverter.divideBy100], + [109, 'energy_reverse_B', tuya.valueConverter.divideBy100], + [129, 'update_frequency', tuya.valueConverter.raw], ], }, }, From b71598e3ac1f30c10db5998b0fb3e70f5f9ca398 Mon Sep 17 00:00:00 2001 From: dams74 Date: Tue, 29 Aug 2023 14:57:55 +0200 Subject: [PATCH 11/15] Update tuya.ts --- src/devices/tuya.ts | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/devices/tuya.ts b/src/devices/tuya.ts index d9834f291b96d..06e6b621bd594 100644 --- a/src/devices/tuya.ts +++ b/src/devices/tuya.ts @@ -5923,7 +5923,7 @@ const definitions: Definition[] = [ whiteLabel: [ tuya.whitelabel('Tuya', 'PJ-1203A', 'Bidirectional Energy Meter with 80A Current Clamp', ['_TZE204_81yrt3lo']), ], - exposes: [ //only report data + exposes: [//only report data e.ac_frequency(), e.numeric('total_power_A', ea.STATE).withUnit('W').withDescription('Total power A'), e.numeric('total_power_B', ea.STATE).withUnit('W').withDescription('Total power B'), @@ -5942,23 +5942,23 @@ const definitions: Definition[] = [ e.numeric('update_frequency', ea.STATE).withUnit('sec').withDescription('Update frequency'), ], meta: { - tuyaDatapoints: [ - [111, 'ac_frequency', tuya.valueConverter.divideBy100], - [101, 'total_power_A', tuya.valueConverter.divideBy10], - [105, 'total_power_B', tuya.valueConverter.divideBy10], - [115, 'total_power_AB', tuya.valueConverter.divideBy10], - [112, 'voltage', tuya.valueConverter.divideBy10], - [113, 'current_A', tuya.valueConverter.divideBy1000], - [114, 'current_B', tuya.valueConverter.divideBy1000], - [110, 'power_factor_A', tuya.valueConverter.divideBy100], - [121, 'power_factor_B', tuya.valueConverter.divideBy100], - [102, 'power_direction A', tuya.valueConverter.raw], - [104, 'power_direction B', tuya.valueConverter.raw], - [106, 'energy_forward_A', tuya.valueConverter.divideBy100], - [108, 'energy_forward_B', tuya.valueConverter.divideBy100], - [107, 'energy_reverse_A', tuya.valueConverter.divideBy100], - [109, 'energy_reverse_B', tuya.valueConverter.divideBy100], - [129, 'update_frequency', tuya.valueConverter.raw], + tuyaDatapoints: [ + [111, 'ac_frequency', tuya.valueConverter.divideBy100], + [101, 'total_power_A', tuya.valueConverter.divideBy10], + [105, 'total_power_B', tuya.valueConverter.divideBy10], + [115, 'total_power_AB', tuya.valueConverter.divideBy10], + [112, 'voltage', tuya.valueConverter.divideBy10], + [113, 'current_A', tuya.valueConverter.divideBy1000], + [114, 'current_B', tuya.valueConverter.divideBy1000], + [110, 'power_factor_A', tuya.valueConverter.divideBy100], + [121, 'power_factor_B', tuya.valueConverter.divideBy100], + [102, 'power_direction A', tuya.valueConverter.raw], + [104, 'power_direction B', tuya.valueConverter.raw], + [106, 'energy_forward_A', tuya.valueConverter.divideBy100], + [108, 'energy_forward_B', tuya.valueConverter.divideBy100], + [107, 'energy_reverse_A', tuya.valueConverter.divideBy100], + [109, 'energy_reverse_B', tuya.valueConverter.divideBy100], + [129, 'update_frequency', tuya.valueConverter.raw], ], }, }, From 9dc7ef7bc7794da72eed196c9c0b6a2d1e8b30cc Mon Sep 17 00:00:00 2001 From: dams74 Date: Tue, 29 Aug 2023 15:06:04 +0200 Subject: [PATCH 12/15] Update tuya.ts --- src/devices/tuya.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/devices/tuya.ts b/src/devices/tuya.ts index 06e6b621bd594..872a3c4e49b7a 100644 --- a/src/devices/tuya.ts +++ b/src/devices/tuya.ts @@ -5913,7 +5913,7 @@ const definitions: Definition[] = [ }, { fingerprint: tuya.fingerprint('TS0601', ['_TZE204_81yrt3lo']), - model: 'TS0601_Bidirectional_Energy_Meter_with_80A_Current_Clamp', + model: 'PJ-1203A', vendor: 'TuYa', description: 'Bidirectional Energy Meter with 80A Current Clamp', fromZigbee: [tuya.fz.datapoints], @@ -5927,7 +5927,7 @@ const definitions: Definition[] = [ e.ac_frequency(), e.numeric('total_power_A', ea.STATE).withUnit('W').withDescription('Total power A'), e.numeric('total_power_B', ea.STATE).withUnit('W').withDescription('Total power B'), - e.numeric('total_power_AB', ea.STATE).withUnit('W').withDescription('Total power A'), + e.numeric('total_power_AB', ea.STATE).withUnit('W').withDescription('Total power A+B'), e.numeric('voltage', ea.STATE).withUnit('V').withDescription('Voltage'), e.numeric('current_A', ea.STATE).withUnit('A').withDescription('Current A'), e.numeric('current_B', ea.STATE).withUnit('A').withDescription('Current B'), @@ -5942,7 +5942,7 @@ const definitions: Definition[] = [ e.numeric('update_frequency', ea.STATE).withUnit('sec').withDescription('Update frequency'), ], meta: { - tuyaDatapoints: [ + tuyaDatapoints: [//only report data [111, 'ac_frequency', tuya.valueConverter.divideBy100], [101, 'total_power_A', tuya.valueConverter.divideBy10], [105, 'total_power_B', tuya.valueConverter.divideBy10], From 41a2c9deaa5e7bf793f0dd457449ea4d00d5ebe4 Mon Sep 17 00:00:00 2001 From: dams74 Date: Tue, 29 Aug 2023 15:11:22 +0200 Subject: [PATCH 13/15] Update tuya.ts --- src/devices/tuya.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/devices/tuya.ts b/src/devices/tuya.ts index 872a3c4e49b7a..18196e1152d6b 100644 --- a/src/devices/tuya.ts +++ b/src/devices/tuya.ts @@ -5923,7 +5923,7 @@ const definitions: Definition[] = [ whiteLabel: [ tuya.whitelabel('Tuya', 'PJ-1203A', 'Bidirectional Energy Meter with 80A Current Clamp', ['_TZE204_81yrt3lo']), ], - exposes: [//only report data + exposes: [ e.ac_frequency(), e.numeric('total_power_A', ea.STATE).withUnit('W').withDescription('Total power A'), e.numeric('total_power_B', ea.STATE).withUnit('W').withDescription('Total power B'), @@ -5942,7 +5942,7 @@ const definitions: Definition[] = [ e.numeric('update_frequency', ea.STATE).withUnit('sec').withDescription('Update frequency'), ], meta: { - tuyaDatapoints: [//only report data + tuyaDatapoints: [ [111, 'ac_frequency', tuya.valueConverter.divideBy100], [101, 'total_power_A', tuya.valueConverter.divideBy10], [105, 'total_power_B', tuya.valueConverter.divideBy10], From 62f63a85d1c1a7f0260f53145f4cc222a2b39dd2 Mon Sep 17 00:00:00 2001 From: Koen Kanters Date: Wed, 30 Aug 2023 08:29:10 +0200 Subject: [PATCH 14/15] Update tuya.ts --- src/lib/tuya.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib/tuya.ts b/src/lib/tuya.ts index 29457dfcc6a93..a08f6b9c49da4 100644 --- a/src/lib/tuya.ts +++ b/src/lib/tuya.ts @@ -254,6 +254,10 @@ const tuyaExposes = { gasValue: () => e.numeric('gas_value', ea.STATE).withDescription('Measured gas concentration'), energyWithPhase: (phase: string) => e.numeric(`energy_${phase}`, ea.STATE).withUnit('kWh') .withDescription(`Sum of consumed energy (phase ${phase.toUpperCase()})`), + energyProducedWithPhase: (phase: string) => e.numeric(`energy_${phase}`, ea.STATE).withUnit('kWh') + .withDescription(`Sum of produced energy (phase ${phase.toUpperCase()})`), + energyFlowWithPhase: (phase: string) => e.enum(`energy_flow_${phase}`, ea.STATE, ['consuming', 'producing']) + .withDescription(`Direction of energy (phase ${phase.toUpperCase()})`), voltageWithPhase: (phase: string) => e.numeric(`voltage_${phase}`, ea.STATE).withUnit('V') .withDescription(`Measured electrical potential value (phase ${phase.toUpperCase()})`), powerWithPhase: (phase: string) => e.numeric(`power_${phase}`, ea.STATE).withUnit('W') From 559d91204d69321eccaac04f552d9ba77f262118 Mon Sep 17 00:00:00 2001 From: Koen Kanters Date: Wed, 30 Aug 2023 08:29:29 +0200 Subject: [PATCH 15/15] Update tuya.ts --- src/devices/tuya.ts | 56 +++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 33 deletions(-) diff --git a/src/devices/tuya.ts b/src/devices/tuya.ts index 18196e1152d6b..f4d0b8474e1c0 100644 --- a/src/devices/tuya.ts +++ b/src/devices/tuya.ts @@ -12,6 +12,7 @@ import {ColorMode, colorModeLookup} from '../lib/constants'; import fz from '../converters/fromZigbee'; import tz from '../converters/toZigbee'; import {KeyValue, Definition, Tz, Fz, Expose, KeyValueAny, KeyValueNumberString, KeyValueString} from '../lib/types'; + const e = exposes.presets; const ea = exposes.access; @@ -5915,49 +5916,38 @@ const definitions: Definition[] = [ fingerprint: tuya.fingerprint('TS0601', ['_TZE204_81yrt3lo']), model: 'PJ-1203A', vendor: 'TuYa', - description: 'Bidirectional Energy Meter with 80A Current Clamp', + description: 'Bidirectional energy meter with 80A current clamp', fromZigbee: [tuya.fz.datapoints], toZigbee: [tuya.tz.datapoints], onEvent: tuya.onEventSetTime, configure: tuya.configureMagicPacket, - whiteLabel: [ - tuya.whitelabel('Tuya', 'PJ-1203A', 'Bidirectional Energy Meter with 80A Current Clamp', ['_TZE204_81yrt3lo']), - ], exposes: [ - e.ac_frequency(), - e.numeric('total_power_A', ea.STATE).withUnit('W').withDescription('Total power A'), - e.numeric('total_power_B', ea.STATE).withUnit('W').withDescription('Total power B'), - e.numeric('total_power_AB', ea.STATE).withUnit('W').withDescription('Total power A+B'), - e.numeric('voltage', ea.STATE).withUnit('V').withDescription('Voltage'), - e.numeric('current_A', ea.STATE).withUnit('A').withDescription('Current A'), - e.numeric('current_B', ea.STATE).withUnit('A').withDescription('Current B'), - e.numeric('power_factor_A', ea.STATE).withUnit('%').withDescription('Instantaneous measured power factor A'), - e.numeric('power_factor_B', ea.STATE).withUnit('%').withDescription('Instantaneous measured power factor B'), - e.numeric('power_direction A', ea.STATE).withDescription('Power direction A 0/1 for forward/reverse'), - e.numeric('power_direction B', ea.STATE).withDescription('Power direction B 0/1 for forward/reverse'), - e.numeric('energy_forward_A', ea.STATE).withUnit('kWh').withDescription('Total energy A forward'), - e.numeric('energy_forward_B', ea.STATE).withUnit('kWh').withDescription('Total energy B forward'), - e.numeric('energy_reverse_A', ea.STATE).withUnit('kWh').withDescription('Total energy A reverse'), - e.numeric('energy_reverse_B', ea.STATE).withUnit('kWh').withDescription('Total energy B reverse'), - e.numeric('update_frequency', ea.STATE).withUnit('sec').withDescription('Update frequency'), + e.ac_frequency(), e.voltage(), + tuya.exposes.powerWithPhase('a'), tuya.exposes.powerWithPhase('b'), tuya.exposes.powerWithPhase('ab'), + tuya.exposes.currentWithPhase('a'), tuya.exposes.currentWithPhase('b'), + tuya.exposes.powerFactorWithPhase('a'), tuya.exposes.powerFactorWithPhase('b'), + tuya.exposes.energyFlowWithPhase('a'), tuya.exposes.energyFlowWithPhase('b'), + tuya.exposes.energyWithPhase('a'), tuya.exposes.energyWithPhase('b'), + tuya.exposes.energyProducedWithPhase('a'), tuya.exposes.energyProducedWithPhase('b'), + e.numeric('update_frequency', ea.STATE).withUnit('s').withDescription('Update frequency'), ], meta: { tuyaDatapoints: [ [111, 'ac_frequency', tuya.valueConverter.divideBy100], - [101, 'total_power_A', tuya.valueConverter.divideBy10], - [105, 'total_power_B', tuya.valueConverter.divideBy10], - [115, 'total_power_AB', tuya.valueConverter.divideBy10], + [101, 'power_a', tuya.valueConverter.divideBy10], + [105, 'power_b', tuya.valueConverter.divideBy10], + [115, 'power_ab', tuya.valueConverter.divideBy10], [112, 'voltage', tuya.valueConverter.divideBy10], - [113, 'current_A', tuya.valueConverter.divideBy1000], - [114, 'current_B', tuya.valueConverter.divideBy1000], - [110, 'power_factor_A', tuya.valueConverter.divideBy100], - [121, 'power_factor_B', tuya.valueConverter.divideBy100], - [102, 'power_direction A', tuya.valueConverter.raw], - [104, 'power_direction B', tuya.valueConverter.raw], - [106, 'energy_forward_A', tuya.valueConverter.divideBy100], - [108, 'energy_forward_B', tuya.valueConverter.divideBy100], - [107, 'energy_reverse_A', tuya.valueConverter.divideBy100], - [109, 'energy_reverse_B', tuya.valueConverter.divideBy100], + [113, 'current_a', tuya.valueConverter.divideBy1000], + [114, 'current_b', tuya.valueConverter.divideBy1000], + [110, 'power_factor_a', tuya.valueConverter.divideBy100], + [121, 'power_factor_b', tuya.valueConverter.divideBy100], + [102, 'energy_flow_a', tuya.valueConverterBasic.lookup({'consuming': 0, 'producing': 1})], + [104, 'energy_flow_b', tuya.valueConverterBasic.lookup({'consuming': 0, 'producing': 1})], + [106, 'energy_a', tuya.valueConverter.divideBy100], + [108, 'energy_b', tuya.valueConverter.divideBy100], + [107, 'energy_produced_A', tuya.valueConverter.divideBy100], + [109, 'energy_produced_B', tuya.valueConverter.divideBy100], [129, 'update_frequency', tuya.valueConverter.raw], ], },