use of org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveAssociationCommandClass in project openhab1-addons by openhab.
the class ZWaveNode method getRoutingList.
/**
* Updates a nodes routing information
* Generation of routes uses associations
*
* @param nodeId
*/
public ArrayList<Integer> getRoutingList() {
logger.debug("NODE {}: Update return routes", nodeId);
// Create a list of nodes this device is configured to talk to
ArrayList<Integer> routedNodes = new ArrayList<Integer>();
// Only update routes if this is a routing node
if (isRouting() == false) {
logger.debug("NODE {}: Node is not a routing node. No routes can be set.", nodeId);
return null;
}
// Get the number of association groups reported by this node
ZWaveAssociationCommandClass associationCmdClass = (ZWaveAssociationCommandClass) getCommandClass(CommandClass.ASSOCIATION);
if (associationCmdClass == null) {
logger.debug("NODE {}: Node has no association class. No routes can be set.", nodeId);
return null;
}
int groups = associationCmdClass.getGroupCount();
if (groups != 0) {
// Loop through each association group and add the node ID to the list
for (int group = 1; group <= groups; group++) {
for (Integer associationNodeId : associationCmdClass.getGroupMembers(group)) {
routedNodes.add(associationNodeId);
}
}
}
// Add the wakeup destination node to the list for battery devices
ZWaveWakeUpCommandClass wakeupCmdClass = (ZWaveWakeUpCommandClass) getCommandClass(CommandClass.WAKE_UP);
if (wakeupCmdClass != null) {
Integer wakeupNodeId = wakeupCmdClass.getTargetNodeId();
routedNodes.add(wakeupNodeId);
}
// Are there any nodes to which we need to set routes?
if (routedNodes.size() == 0) {
logger.debug("NODE {}: No return routes required.", nodeId);
return null;
}
return routedNodes;
}
Aggregations