Skip to content

Commit

Permalink
Add handleRemoval handler to send leave command to device (#98)
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Jackson <chris@cd-jackson.com>
  • Loading branch information
cdjackson committed Jan 17, 2018
1 parent 7c3b8f9 commit 87fe171
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ESH-INF/thing/_controller_telegesis.xml
Expand Up @@ -97,7 +97,7 @@
<options>
<option value="TC_JOIN_DENY">Deny all joins</option>
<option value="TC_JOIN_SECURE">Allow only secure joining</option>
<option value="TC_JOIN_INSECURE">All all joins</option>
<option value="TC_JOIN_INSECURE">Allow all joins</option>
</options>
<default>TC_JOIN_SECURE</default>
<advanced>true</advanced>
Expand Down
Expand Up @@ -693,7 +693,6 @@ public boolean leave(IeeeAddress address) {
logger.debug("{}: ZigBee leave command to {}", address, node.getNetworkAddress());

networkManager.leave(node.getNetworkAddress(), node.getIeeeAddress());
// networkManager.leave(ZigBeeBroadcastDestination.BROADCAST_ALL_DEVICES.getKey(), node.getIeeeAddress());
return true;
}

Expand Down
Expand Up @@ -226,6 +226,7 @@ private synchronized void doNodeInitialisation() {
continue;
}

logger.debug("{}: Initializing channel {} with {}", nodeIeeeAddress, channel.getUID(), handler);
handler.initializeConverter();

// TODO: Update the channel configuration from the device if method available
Expand All @@ -242,6 +243,7 @@ private synchronized void doNodeInitialisation() {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.HANDLER_INITIALIZING_ERROR);
return;
}
logger.debug("{}: Channel initialisation complete", nodeIeeeAddress);

// Update the general properties
ZigBeeNodePropertyDiscoverer propertyDiscoverer = new ZigBeeNodePropertyDiscoverer();
Expand Down Expand Up @@ -367,6 +369,12 @@ public void channelUnlinked(ChannelUID channelUID) {
thingChannelsPoll.remove(channelUID);
}

@Override
public void handleRemoval() {
coordinatorHandler.leave(nodeIeeeAddress);
updateStatus(ThingStatus.REMOVED);
}

@Override
public void handleConfigurationUpdate(Map<String, Object> configurationParameters) {
logger.debug("{}: Configuration received: {}", nodeIeeeAddress, configurationParameters);
Expand Down

0 comments on commit 87fe171

Please sign in to comment.