From 9a66b04cb3e48fa9bfa163bafdff17b5ce6965d8 Mon Sep 17 00:00:00 2001 From: Koen Kanters Date: Mon, 18 Feb 2019 17:42:50 +0100 Subject: [PATCH] Coordinator group is not needed anymore. #102 --- lib/controller.js | 2 -- lib/extension/coordinatorGroup.js | 56 ------------------------------- lib/zigbee.js | 24 ------------- 3 files changed, 82 deletions(-) delete mode 100644 lib/extension/coordinatorGroup.js diff --git a/lib/controller.js b/lib/controller.js index 1c9fc0b41d..b5276187c4 100644 --- a/lib/controller.js +++ b/lib/controller.js @@ -19,7 +19,6 @@ const ExtensionBridgeConfig = require('./extension/bridgeConfig'); const ExtensionGroups = require('./extension/groups'); const ExtensionDeviceAvailability = require('./extension/deviceAvailability'); const ExtensionDeviceBind = require('./extension/deviceBind'); -const ExtensionCoordinatorGroup = require('./extension/coordinatorGroup'); const ExtensionDeviceReport = require('./extension/deviceReport'); const ExtensionLivolo = require('./extension/livolo'); @@ -45,7 +44,6 @@ class Controller { new ExtensionBridgeConfig(this.zigbee, this.mqtt, this.state, this.publishEntityState), new ExtensionGroups(this.zigbee, this.mqtt, this.state, this.publishEntityState), new ExtensionDeviceBind(this.zigbee, this.mqtt, this.state, this.publishEntityState), - new ExtensionCoordinatorGroup(this.zigbee, this.mqtt, this.state, this.publishEntityState), new ExtensionDeviceReport(this.zigbee, this.mqtt, this.state, this.publishEntityState), ]; diff --git a/lib/extension/coordinatorGroup.js b/lib/extension/coordinatorGroup.js deleted file mode 100644 index a2c746ba03..0000000000 --- a/lib/extension/coordinatorGroup.js +++ /dev/null @@ -1,56 +0,0 @@ -const zigbeeShepherdConvertersDevices = require('zigbee-shepherd-converters').devices; -const settings = require('../util/settings'); -const logger = require('../util/logger'); - -// IKEA TRADFRI remote control -const E1524 = zigbeeShepherdConvertersDevices.find((d) => d.model === 'E1524'); -const MLI_404011 = zigbeeShepherdConvertersDevices.find((d) => d.model === 'MLI-404011'); - -const devices = [E1524, MLI_404011]; - -/** - * This extensions adds the coordinator to a group which is required for some devices to work properly. - */ -class CoordinatorGroup { - constructor(zigbee, mqtt, state, publishEntityState) { - this.zigbee = zigbee; - this.mqtt = mqtt; - this.state = state; - this.publishEntityState = publishEntityState; - } - - onZigbeeStarted() { - this.zigbee.getAllClients().forEach((device) => { - devices.forEach((mappedDevice) => { - if (mappedDevice.zigbeeModel.includes(device.modelId)) { - this.setup(mappedDevice, device); - } - }); - }); - } - - setup(mappedDevice, device) { - const deviceLog = `${mappedDevice.vendor} ${mappedDevice.description} (${device.ieeeAddr})`; - - // Check if there is a coordinator_group defined for this device. - const deviceSettings = settings.getDevice(device.ieeeAddr); - if (!deviceSettings || !deviceSettings.coordinator_group) { - logger.error( - `Device ${deviceLog} requires extra configuration!` + - ` Please see http://www.zigbee2mqtt.io/information/coordinator_group.md` - ); - return; - } - - // Add the coordinator to the group, first check if it's already in the group. - this.zigbee.addCoordinatorToGroup(deviceSettings.coordinator_group, (error) => { - if (!error) { - logger.info(`Successfully applied coordinator group for ${deviceLog}`); - } else { - logger.error(`Failed to apply coordinator group for ${deviceLog}`); - } - }); - } -} - -module.exports = CoordinatorGroup; diff --git a/lib/zigbee.js b/lib/zigbee.js index 710fe34d76..dc981de264 100644 --- a/lib/zigbee.js +++ b/lib/zigbee.js @@ -118,9 +118,6 @@ class Zigbee { this.shepherd.controller.request('UTIL', 'ledControl', {ledid: 3, mode: 0}); } - // Add the coordinator to group 99 - this.addCoordinatorToGroup(99); - // Wait some time before we start the queue, many calls skip this queue which hangs the stick setTimeout(() => { this.queue.autostart = true; @@ -130,27 +127,6 @@ class Zigbee { logger.info('zigbee-shepherd ready'); } - addCoordinatorToGroup(groupID, callback=() => {}) { - this.shepherd.controller.request('ZDO', 'extFindGroup', {groupid: groupID, endpoint: 1}, (err) => { - // Error means that the coordinator is not in the group yet. - if (err) { - const payload = {groupid: groupID, endpoint: 1, namelen: 0, groupname: ''}; - this.shepherd.controller.request('ZDO', 'extAddGroup', payload, (err) => { - if (err) { - logger.info(`Successfully added coordinator to group '${groupID}'`); - callback(false); - } else { - logger.error(`Failed to add coordinator to group '${groupID}'`); - callback(true); - } - }); - } else { - logger.debug(`Coordinator is already in group '${groupID}'`); - callback(false); - } - }); - } - onError(message) { // This event may appear if zigbee-shepherd cannot decode bad packets (invalid checksum). logger.error(message);