Search in sources :

Example 6 with ZWaveAssociationCommandClass

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;
}
Also used : ZWaveAssociationCommandClass(org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveAssociationCommandClass) ArrayList(java.util.ArrayList) ZWaveWakeUpCommandClass(org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveWakeUpCommandClass)

Aggregations

ZWaveAssociationCommandClass (org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveAssociationCommandClass)6 ZWaveWakeUpCommandClass (org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveWakeUpCommandClass)6 ZWaveNode (org.openhab.binding.zwave.internal.protocol.ZWaveNode)4 ZWaveConfigurationCommandClass (org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveConfigurationCommandClass)4 ArrayList (java.util.ArrayList)3 ZWaveNodeSerializer (org.openhab.binding.zwave.internal.protocol.initialization.ZWaveNodeSerializer)3 List (java.util.List)2 ConfigurationParameter (org.openhab.binding.zwave.internal.protocol.ConfigurationParameter)2 SerialMessage (org.openhab.binding.zwave.internal.protocol.SerialMessage)2 ZWaveNoOperationCommandClass (org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveNoOperationCommandClass)2 ZWaveSwitchAllCommandClass (org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveSwitchAllCommandClass)2 ZWaveVersionCommandClass (org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveVersionCommandClass)2 Date (java.util.Date)1 ZWaveDbAssociationGroup (org.openhab.binding.zwave.internal.config.ZWaveDbAssociationGroup)1 ZWaveDbCommandClass (org.openhab.binding.zwave.internal.config.ZWaveDbCommandClass)1 ZWaveDbConfigurationParameter (org.openhab.binding.zwave.internal.config.ZWaveDbConfigurationParameter)1 ZWaveProductDatabase (org.openhab.binding.zwave.internal.config.ZWaveProductDatabase)1 ZWaveDeviceClass (org.openhab.binding.zwave.internal.protocol.ZWaveDeviceClass)1 ZWaveDeviceType (org.openhab.binding.zwave.internal.protocol.ZWaveDeviceType)1 ZWaveEndpoint (org.openhab.binding.zwave.internal.protocol.ZWaveEndpoint)1