Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tuya.ts #6116

Merged
merged 15 commits into from
Aug 30, 2023
50 changes: 49 additions & 1 deletion src/devices/tuya.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -5912,6 +5911,55 @@ 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
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;