From ae08deb2fd563922f5fda553b67d85bb91292c51 Mon Sep 17 00:00:00 2001 From: Koen Kanters Date: Sat, 2 Feb 2019 00:31:30 +0100 Subject: [PATCH] Refactor and remove unnecessary bind. #966 --- lib/extension/reporting.js | 6 ++---- lib/zigbee.js | 6 +++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/extension/reporting.js b/lib/extension/reporting.js index ebb7c1372..dedf52926 100644 --- a/lib/extension/reporting.js +++ b/lib/extension/reporting.js @@ -8,7 +8,7 @@ const candidates = { }; const reportInterval = { - min: 2, + min: 1, max: 3600, }; @@ -40,9 +40,7 @@ class Reporting { if (candidates[cluster]) { const attributes = candidates[cluster].filter((a) => c.attrs.hasOwnProperty(a)); attributes.forEach((attribute) => { - this.zigbee.endpointBindCoordinator(endpoint, cluster); - - this.zigbee.endpointReport( + this.zigbee.report( endpoint, cluster, attribute, diff --git a/lib/zigbee.js b/lib/zigbee.js index 1bb3f4ab5..6c27e40c2 100644 --- a/lib/zigbee.js +++ b/lib/zigbee.js @@ -274,12 +274,12 @@ class Zigbee { return endpoint; } - endpointBindCoordinator(ep, cluster) { + bind(ep, cluster, target=this.getCoordinator()) { const log = `for ${ep.device.ieeeAddr} - ${cluster}`; this.queue.push((queueCallback) => { logger.debug(`Setup binding ${log}`); - ep.bind(cluster, this.getCoordinator(), (error) => { + ep.bind(cluster, target, (error) => { if (error) { logger.error(`Failed to setup binding ${log} - (${error})`); } else { @@ -291,7 +291,7 @@ class Zigbee { }); } - endpointReport(ep, cluster, attribute, min, max, change) { + report(ep, cluster, attribute, min, max, change) { const attrId = zclId.attr(cluster, attribute).value; const dataType = zclId.attrType(cluster, attribute).value; const cfg = {direction: 0, attrId, dataType, minRepIntval: min, maxRepIntval: max, repChange: change};