diff --git a/lib/extension/groups.js b/lib/extension/groups.js index e7f5104280..f11c773087 100644 --- a/lib/extension/groups.js +++ b/lib/extension/groups.js @@ -48,6 +48,11 @@ class Groups { return; } + if (groupID === 99) { + logger.error('Group 99 is reserved, please use a different groupID'); + return; + } + // Map message to ieeeAddr and check if device exist. message = message.toString(); const ieeeAddr = settings.getIeeeAddrByFriendlyName(message) || message; diff --git a/lib/zigbee.js b/lib/zigbee.js index ab17a27750..379074f22a 100644 --- a/lib/zigbee.js +++ b/lib/zigbee.js @@ -113,6 +113,23 @@ class Zigbee { this.shepherd.controller.request('UTIL', 'ledControl', {ledid: 3, mode: 0}); } + // Add the coordinator to group 99 + this.shepherd.controller.request('ZDO', 'extFindGroup', {groupid: 99, endpoint: 1}, (err) => { + // Error means that the coordinator is not in the group yet. + if (err) { + const payload = {groupid: 99, endpoint: 1, namelen: 0, groupname: ''}; + this.shepherd.controller.request('ZDO', 'extAddGroup', payload, (err) => { + if (err) { + logger.info('Successfully added coordinator to group 99'); + } else { + logger.error('Failed to add coordinator to group 99'); + } + }); + } else { + logger.debug('Coordinator is already in group 99'); + } + }); + // Wait some time before we start the queue, many calls skip this queue which hangs the stick setTimeout(() => { this.queue.autostart = true;