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

Add SPM01V2 data report duration configuration #8843

Merged
merged 3 commits into from
Feb 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions src/devices/tuya.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9673,6 +9673,13 @@ export const definitions: DefinitionWithExtend[] = [
e.produced_energy().withDescription('Total reverse active energy'),
e.power_factor().withUnit('%'),
e.ac_frequency(),
e
.numeric('data_report_duration', ea.SET)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.numeric('data_report_duration', ea.SET)
.numeric('data_report_interval', ea.SET)

Would this name make more sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am ok either way, the reason for the name I used is that in Tuya app that is how it is called when updating firmware - see screenshot here.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then let's keep it like this.

.withValueMin(5)
.withValueMax(3600)
.withDescription(
'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)',
),
],
meta: {
tuyaDatapoints: [
Expand All @@ -9681,6 +9688,46 @@ export const definitions: DefinitionWithExtend[] = [
// [6, null, tuya.valueConverter.phaseVariant3],
[15, 'power_factor', tuya.valueConverter.raw],
// [16, 'clear_energy', tuya.valueConverter.onOff],
[
18,
'data_report_duration',
{
to: (v: number) => {
const value = Math.max(5, Math.min(3600, Math.round(v)));
const byte1 = (value >> 8) & 0xff;
const byte2 = value & 0xff;
return [
// Unknown what these bytes mean, possibly configures other settings of the device
0x01,
0x01,
0x00,
0x3c,
0x03,
0x01,
0x00,
0xfd,
0x04,
0x00,
0x00,
0xb4,
0x07,
0x01,
0x00,
0x00,
0x08,
0x01,
// Report duration
byte1,
byte2,
// Unknown what these bytes mean, possibly configures other settings of the device
0x09,
0x00,
0x00,
0x00,
];
},
},
],
[101, 'ac_frequency', tuya.valueConverter.divideBy100],
[102, 'voltage', tuya.valueConverter.divideBy10],
[103, 'current', tuya.valueConverter.divideBy1000],
Expand Down