Skip to content

Commit

Permalink
Add coordinator to group 99 by default. #997
Browse files Browse the repository at this point in the history
  • Loading branch information
Koenkk committed Feb 6, 2019
1 parent f4bf504 commit 443a14e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/extension/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 17 additions & 0 deletions lib/zigbee.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 443a14e

Please sign in to comment.