Skip to content

Commit

Permalink
feat(add): PJ-1203A (#6116)
Browse files Browse the repository at this point in the history
* Update tuya.ts

Update with new device
Koenkk/zigbee2mqtt#18419

* Update tuya.ts

* Update tuya.ts

sorry an other update

* Update tuya.ts

other update

* Update tuya.ts

update

* Update tuya.ts

update

* Update tuya.ts

update

* Update tuya.ts

update

* Update tuya.ts

* Update tuya.ts

* Update tuya.ts

* Update tuya.ts

* Update tuya.ts

* Update tuya.ts

* Update tuya.ts

---------

Co-authored-by: Koen Kanters <koenkanters94@gmail.com>
  • Loading branch information
dams74 and Koenkk authored Aug 30, 2023
1 parent eb83e94 commit 888918c
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/devices/tuya.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5912,6 +5912,46 @@ const definitions: Definition[] = [
],
},
},
{
fingerprint: tuya.fingerprint('TS0601', ['_TZE204_81yrt3lo']),
model: 'PJ-1203A',
vendor: 'TuYa',
description: 'Bidirectional energy meter with 80A current clamp',
fromZigbee: [tuya.fz.datapoints],
toZigbee: [tuya.tz.datapoints],
onEvent: tuya.onEventSetTime,
configure: tuya.configureMagicPacket,
exposes: [
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, '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, '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],
],
},
},
];

module.exports = definitions;
4 changes: 4 additions & 0 deletions src/lib/tuya.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 888918c

Please sign in to comment.