Skip to content

Commit c4817bd

Browse files
author
Nicolas THIERS
committed
fix: remove logger (3rd param is definition), inline seMetering calls to fix TS types
1 parent 0d46118 commit c4817bd

1 file changed

Lines changed: 16 additions & 31 deletions

File tree

src/devices/nodon.ts

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ export const definitions: DefinitionWithExtend[] = [
329329
.withCategory('config'),
330330
e.power_apparent(),
331331
],
332-
configure: async (device, coordinatorEndpoint, logger) => {
332+
configure: async (device, coordinatorEndpoint) => {
333333
const endpoint = device.getEndpoint(1);
334334

335335
// Explicit bind — not done by m.electricityMeter because configureReporting: false
@@ -345,37 +345,22 @@ export const definitions: DefinitionWithExtend[] = [
345345
await endpoint.read('seMetering', ['multiplier', 'divisor']);
346346

347347
// Split into batches of ≤5 to stay within the ~85-byte ZCL frame limit
348-
try {
349-
await endpoint.configureReporting('haElectricalMeasurement', [
350-
{attribute: 'acFrequency', minimumReportInterval: 30, maximumReportInterval: 3600, reportableChange: 500}, // 5 Hz
351-
{attribute: 'rmsVoltage', minimumReportInterval: 30, maximumReportInterval: 3600, reportableChange: 2300}, // 23 V
352-
{attribute: 'rmsCurrent', minimumReportInterval: 10, maximumReportInterval: 3600, reportableChange: 100}, // 1 A
353-
{attribute: 'activePower', minimumReportInterval: 10, maximumReportInterval: 3600, reportableChange: 250}, // 250 W
354-
{attribute: 'apparentPower', minimumReportInterval: 10, maximumReportInterval: 3600, reportableChange: 250}, // 250 VA
355-
]);
356-
} catch (error) {
357-
logger.debug(`SEM-4-1-00: haElectricalMeasurement batch 1 configureReporting failed: ${(error as Error).message}`);
358-
}
359-
try {
360-
await endpoint.configureReporting('haElectricalMeasurement', [
361-
{attribute: 'powerFactor', minimumReportInterval: 60, maximumReportInterval: 3600, reportableChange: 20}, // 0.20
362-
]);
363-
} catch (error) {
364-
logger.debug(`SEM-4-1-00: haElectricalMeasurement batch 2 configureReporting failed: ${(error as Error).message}`);
365-
}
366-
367-
const seAttrs = [
348+
await endpoint.configureReporting('haElectricalMeasurement', [
349+
{attribute: 'acFrequency', minimumReportInterval: 30, maximumReportInterval: 3600, reportableChange: 500}, // 5 Hz
350+
{attribute: 'rmsVoltage', minimumReportInterval: 30, maximumReportInterval: 3600, reportableChange: 2300}, // 23 V
351+
{attribute: 'rmsCurrent', minimumReportInterval: 10, maximumReportInterval: 3600, reportableChange: 100}, // 1 A
352+
{attribute: 'activePower', minimumReportInterval: 10, maximumReportInterval: 3600, reportableChange: 250}, // 250 W
353+
{attribute: 'apparentPower', minimumReportInterval: 10, maximumReportInterval: 3600, reportableChange: 250}, // 250 VA
354+
]);
355+
await endpoint.configureReporting('haElectricalMeasurement', [
356+
{attribute: 'powerFactor', minimumReportInterval: 60, maximumReportInterval: 3600, reportableChange: 20}, // 0.20
357+
]);
358+
await endpoint.configureReporting('seMetering', [
368359
{attribute: 'currentSummDelivered', minimumReportInterval: 300, maximumReportInterval: 3600, reportableChange: 100}, // 0.1 kWh
369-
{attribute: 'currentSummReceived', minimumReportInterval: 300, maximumReportInterval: 3600, reportableChange: 100}, // 0.1 kWh
370-
];
371-
372-
for (const attr of seAttrs) {
373-
try {
374-
await endpoint.configureReporting('seMetering', [attr]);
375-
} catch (error) {
376-
logger.debug(`SEM-4-1-00: seMetering/${attr.attribute} configureReporting failed: ${(error as Error).message}`);
377-
}
378-
}
360+
]);
361+
await endpoint.configureReporting('seMetering', [
362+
{attribute: 'currentSummReceived', minimumReportInterval: 300, maximumReportInterval: 3600, reportableChange: 100}, // 0.1 kWh
363+
]);
379364
},
380365
ota: true,
381366
},

0 commit comments

Comments
 (0)