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
48 changes: 46 additions & 2 deletions src/devices/tuya.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
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 @@ -5913,5 +5912,50 @@
},
},
];

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'),

Check failure on line 5925 in src/devices/tuya.ts

View workflow job for this annotation

GitHub Actions / ci

Property 'numeric' does not exist on type 'typeof import("/home/runner/work/zigbee-herdsman-converters/zigbee-herdsman-converters/src/lib/exposes")'. Did you mean 'Numeric'?
exposes.numeric('total_power_B', ea.STATE).withUnit('W').withDescription('Total power B'),

Check failure on line 5926 in src/devices/tuya.ts

View workflow job for this annotation

GitHub Actions / ci

Property 'numeric' does not exist on type 'typeof import("/home/runner/work/zigbee-herdsman-converters/zigbee-herdsman-converters/src/lib/exposes")'. Did you mean 'Numeric'?
exposes.numeric('total_power_AB', ea.STATE).withUnit('W').withDescription('Total power A'),

Check failure on line 5927 in src/devices/tuya.ts

View workflow job for this annotation

GitHub Actions / ci

Property 'numeric' does not exist on type 'typeof import("/home/runner/work/zigbee-herdsman-converters/zigbee-herdsman-converters/src/lib/exposes")'. Did you mean 'Numeric'?
exposes.numeric('voltage', ea.STATE).withUnit('V').withDescription('Voltage'),

Check failure on line 5928 in src/devices/tuya.ts

View workflow job for this annotation

GitHub Actions / ci

Property 'numeric' does not exist on type 'typeof import("/home/runner/work/zigbee-herdsman-converters/zigbee-herdsman-converters/src/lib/exposes")'. Did you mean 'Numeric'?
exposes.numeric('current_A', ea.STATE).withUnit('A').withDescription('Current A'),

Check failure on line 5929 in src/devices/tuya.ts

View workflow job for this annotation

GitHub Actions / ci

Property 'numeric' does not exist on type 'typeof import("/home/runner/work/zigbee-herdsman-converters/zigbee-herdsman-converters/src/lib/exposes")'. Did you mean 'Numeric'?
exposes.numeric('current_B', ea.STATE).withUnit('A').withDescription('Current B'),

Check failure on line 5930 in src/devices/tuya.ts

View workflow job for this annotation

GitHub Actions / ci

Property 'numeric' does not exist on type 'typeof import("/home/runner/work/zigbee-herdsman-converters/zigbee-herdsman-converters/src/lib/exposes")'. Did you mean 'Numeric'?
exposes.numeric('power_factor_A', ea.STATE).withUnit('%').withDescription('Instantaneous measured power factor A'),

Check failure on line 5931 in src/devices/tuya.ts

View workflow job for this annotation

GitHub Actions / ci

Property 'numeric' does not exist on type 'typeof import("/home/runner/work/zigbee-herdsman-converters/zigbee-herdsman-converters/src/lib/exposes")'. Did you mean 'Numeric'?
exposes.numeric('power_factor_B', ea.STATE).withUnit('%').withDescription('Instantaneous measured power factor B'),

Check failure on line 5932 in src/devices/tuya.ts

View workflow job for this annotation

GitHub Actions / ci

Property 'numeric' does not exist on type 'typeof import("/home/runner/work/zigbee-herdsman-converters/zigbee-herdsman-converters/src/lib/exposes")'. Did you mean 'Numeric'?
exposes.numeric('power_direction A', ea.STATE).withDescription('Power direction A 0/1 for forward/reverse'),

Check failure on line 5933 in src/devices/tuya.ts

View workflow job for this annotation

GitHub Actions / ci

Property 'numeric' does not exist on type 'typeof import("/home/runner/work/zigbee-herdsman-converters/zigbee-herdsman-converters/src/lib/exposes")'. Did you mean 'Numeric'?
exposes.numeric('power_direction B', ea.STATE).withDescription('Power direction B 0/1 for forward/reverse'),

Check failure on line 5934 in src/devices/tuya.ts

View workflow job for this annotation

GitHub Actions / ci

Property 'numeric' does not exist on type 'typeof import("/home/runner/work/zigbee-herdsman-converters/zigbee-herdsman-converters/src/lib/exposes")'. Did you mean 'Numeric'?
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],
],
},
};
module.exports = definitions;