Skip to content

Commit fbe5296

Browse files
authored
feat: Support data_report_duration for Tuya SPM01V2 (#8843)
1 parent 659bf7d commit fbe5296

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

src/devices/tuya.ts

+47
Original file line numberDiff line numberDiff line change
@@ -9673,6 +9673,13 @@ export const definitions: DefinitionWithExtend[] = [
96739673
e.produced_energy().withDescription('Total reverse active energy'),
96749674
e.power_factor().withUnit('%'),
96759675
e.ac_frequency(),
9676+
e
9677+
.numeric('data_report_duration', ea.SET)
9678+
.withValueMin(5)
9679+
.withValueMax(3600)
9680+
.withDescription(
9681+
'WARNING: You must update device firmware to V3.1.3 before changing this setting! Use Tuya gateway/app to update firmware. Data report duration set (Threshold value range 5~3600 seconds)',
9682+
),
96769683
],
96779684
meta: {
96789685
tuyaDatapoints: [
@@ -9681,6 +9688,46 @@ export const definitions: DefinitionWithExtend[] = [
96819688
// [6, null, tuya.valueConverter.phaseVariant3],
96829689
[15, 'power_factor', tuya.valueConverter.raw],
96839690
// [16, 'clear_energy', tuya.valueConverter.onOff],
9691+
[
9692+
18,
9693+
'data_report_duration',
9694+
{
9695+
to: (v: number) => {
9696+
const value = Math.max(5, Math.min(3600, Math.round(v)));
9697+
const byte1 = (value >> 8) & 0xff;
9698+
const byte2 = value & 0xff;
9699+
return [
9700+
// Unknown what these bytes mean, possibly configures other settings of the device
9701+
0x01,
9702+
0x01,
9703+
0x00,
9704+
0x3c,
9705+
0x03,
9706+
0x01,
9707+
0x00,
9708+
0xfd,
9709+
0x04,
9710+
0x00,
9711+
0x00,
9712+
0xb4,
9713+
0x07,
9714+
0x01,
9715+
0x00,
9716+
0x00,
9717+
0x08,
9718+
0x01,
9719+
// Report duration
9720+
byte1,
9721+
byte2,
9722+
// Unknown what these bytes mean, possibly configures other settings of the device
9723+
0x09,
9724+
0x00,
9725+
0x00,
9726+
0x00,
9727+
];
9728+
},
9729+
},
9730+
],
96849731
[101, 'ac_frequency', tuya.valueConverter.divideBy100],
96859732
[102, 'voltage', tuya.valueConverter.divideBy10],
96869733
[103, 'current', tuya.valueConverter.divideBy1000],

0 commit comments

Comments
 (0)