Skip to content

Commit 42a3c21

Browse files
Lacrymal3Koenkk
andauthored
feat: OWON PC 321 - support clear measurement data (#7895)
* OWON PC 321 - Add clear measurement data * Update owon.ts * updates --------- Co-authored-by: Koen Kanters <[email protected]>
1 parent f843534 commit 42a3c21

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/devices/owon.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as legacy from '../lib/legacy';
66
import {battery, iasZoneAlarm} from '../lib/modernExtend';
77
import * as reporting from '../lib/reporting';
88
import * as tuya from '../lib/tuya';
9-
import {DefinitionWithExtend, Fz, KeyValue} from '../lib/types';
9+
import {DefinitionWithExtend, Fz, KeyValue, Tz} from '../lib/types';
1010
const e = exposes.presets;
1111
const ea = exposes.access;
1212

@@ -127,6 +127,15 @@ const fzLocal = {
127127
} satisfies Fz.Converter,
128128
};
129129

130+
const tzLocal = {
131+
PC321_clearMetering: {
132+
key: ['clear_metering'],
133+
convertSet: async (entity, key, value, meta) => {
134+
await entity.command(0xffe0, 0x00, {}, {disableDefaultResponse: true});
135+
},
136+
} satisfies Tz.Converter,
137+
};
138+
130139
const definitions: DefinitionWithExtend[] = [
131140
{
132141
zigbeeModel: ['WSP402'],
@@ -302,7 +311,7 @@ const definitions: DefinitionWithExtend[] = [
302311
vendor: 'OWON',
303312
description: '3-Phase clamp power meter',
304313
fromZigbee: [fz.metering, fzLocal.PC321_metering],
305-
toZigbee: [],
314+
toZigbee: [tzLocal.PC321_clearMetering],
306315
configure: async (device, coordinatorEndpoint) => {
307316
const endpoint = device.getEndpoint(1);
308317
await reporting.bind(endpoint, coordinatorEndpoint, ['seMetering']);
@@ -340,6 +349,7 @@ const definitions: DefinitionWithExtend[] = [
340349
e.numeric('power_factor_l1', ea.STATE).withUnit('%').withDescription('Phase 1 power factor'),
341350
e.numeric('power_factor_l2', ea.STATE).withUnit('%').withDescription('Phase 2 power factor'),
342351
e.numeric('power_factor_l3', ea.STATE).withUnit('%').withDescription('Phase 3 power factor'),
352+
e.enum('clear_metering', ea.SET, ['clear']).withDescription('Clear measurement data'),
343353
],
344354
},
345355
{

0 commit comments

Comments
 (0)