Skip to content

Commit

Permalink
MOSZB-140 some minor cleanup and fixes (#4741)
Browse files Browse the repository at this point in the history
* utils: postfixWithEndpointName should handle "undefined" better

e.g. the MOSZB-140 has 35 as the default endpoint, most of the config on genBasic, genPowerCfg and ssIasZone are there.
Additionally it uses seperate endpoints for temperature and illumance (40 and 39). It also has 3 (!!) msOccupancySensing endpoints (34, 40, 41), for those we do want to provide a suffix to the property name.

For those we don't really need a suffix for the propery name, having `{default: 35, 'logic_a': 34, 'logic_b': 40, 'logic_c': 41}` mostly works but tempeature now has _undefined appended.
With this change, instead of appending undefined, we just return the original proporty.

* MOSZB-140: cleanup

- drop read of batteryVoltage, reporting configuration does this
- update reporting settings to match with the suggestions from develco
  (esp illumantion was very spanny and battery draining with the defaults)

* MOSZB-140: try/catch on read of develcoAlarmOffDelay/develcoLedControl

There was a issue were configure kept failing due to timeouts on reading these.
As show in #4731 the tech manual might not be 100%
 accurate. So putting them in a try/catch should at least let the configuration continue settings up everything else.
  • Loading branch information
sjorge committed Oct 5, 2022
1 parent a7c2e35 commit 9c6d8c6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
27 changes: 15 additions & 12 deletions devices/develco.js
Original file line number Diff line number Diff line change
Expand Up @@ -516,20 +516,23 @@ module.exports = [
return {default: 35};
},
configure: async (device, coordinatorEndpoint, logger) => {
const endpoint1 = device.getEndpoint(35);
await reporting.bind(endpoint1, coordinatorEndpoint, ['genPowerCfg']);
await reporting.batteryVoltage(endpoint1, {min: constants.repInterval.HOUR, max: 43200, change: 100});
await endpoint1.read('genPowerCfg', ['batteryVoltage']);
await endpoint1.read('genBasic', ['develcoLedControl'], manufacturerOptions);
await endpoint1.read('ssIasZone', ['develcoAlarmOffDelay'], manufacturerOptions);
const endpoint35 = device.getEndpoint(35);
await reporting.bind(endpoint35, coordinatorEndpoint, ['genPowerCfg']);
await reporting.batteryVoltage(endpoint35, {min: constants.repInterval.HOUR, max: 43200, change: 100});
try {
await endpoint35.read('ssIasZone', ['develcoAlarmOffDelay'], manufacturerOptions);
await endpoint35.read('genBasic', ['develcoLedControl'], manufacturerOptions);
} catch (error) {/* some reports of timeouts on reading these */}

const endpoint2 = device.getEndpoint(38);
await reporting.bind(endpoint2, coordinatorEndpoint, ['msTemperatureMeasurement']);
await reporting.temperature(endpoint2);
const endpoint38 = device.getEndpoint(38);
await reporting.bind(endpoint38, coordinatorEndpoint, ['msTemperatureMeasurement']);
await reporting.temperature(endpoint38,
{min: constants.repInterval.MINUTE, max: constants.repInterval.MINUTES_10, change: 100});

const endpoint3 = device.getEndpoint(39);
await reporting.bind(endpoint3, coordinatorEndpoint, ['msIlluminanceMeasurement']);
await reporting.illuminance(endpoint3);
const endpoint39 = device.getEndpoint(39);
await reporting.bind(endpoint39, coordinatorEndpoint, ['msIlluminanceMeasurement']);
await reporting.illuminance(endpoint39,
{min: constants.repInterval.MINUTE, max: constants.repInterval.MINUTES_10, change: 500});
},
},
{
Expand Down
8 changes: 5 additions & 3 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,12 @@ function postfixWithEndpointName(value, msg, definition, meta) {
if (definition.meta && definition.meta.multiEndpoint) {
const endpointName = definition.hasOwnProperty('endpoint') ?
getKey(definition.endpoint(meta.device), msg.endpoint.ID) : msg.endpoint.ID;
return `${value}_${endpointName}`;
} else {
return value;

// NOTE: endpointName can be undefined if we have a definition.endpoint and the endpoint is
// not listed.
if (endpointName) return `${value}_${endpointName}`;
}
return value;
}

function getKey(object, value, fallback, convertTo) {
Expand Down

0 comments on commit 9c6d8c6

Please sign in to comment.