Examples of ZWaveNode


Examples of org.openhab.binding.zwave.internal.protocol.ZWaveNode

  @Override
  public  boolean handleRequest(ZWaveController zController, SerialMessage lastSentMessage, SerialMessage incomingMessage) {
    logger.trace("Handle Message Application Command Request");
    int nodeId = incomingMessage.getMessagePayloadByte(1);
    ZWaveNode node = zController.getNode(nodeId);
   
    if (node == null) {
      logger.warn("NODE {}: Not initialized yet, ignoring message.", nodeId);
      return false;
    }
    logger.debug("NODE {}: Application Command Request (Stage {})", nodeId, node.getNodeStage().getLabel());
   
    // If the node is DEAD, but we've just received a message from it, then it's not dead!
    if(node.isDead()) {
      node.setAlive();
      logger.debug("NODE {}: Node has risen from the DEAD. Set stage to {}.", nodeId, node.getNodeStage());     
    }
   
    node.resetResendCount();
    node.incrementReceiveCount();
   
    int commandClassCode = incomingMessage.getMessagePayloadByte(3);
    CommandClass commandClass = CommandClass.getCommandClass(commandClassCode);

    if (commandClass == null) {
      logger.error(String.format("NODE %d: Unsupported command class 0x%02x", nodeId, commandClassCode));
      return false;
    }

    logger.debug(String.format("NODE %d: Incoming command class %s (0x%02x)", nodeId, commandClass.getLabel(), commandClass.getKey()));
    ZWaveCommandClass zwaveCommandClass =  node.getCommandClass(commandClass);
   
    // Apparently, this node supports a command class that we did not get (yet) during initialization.
    // Let's add it now then to support handling this message.
    if (zwaveCommandClass == null) {
      logger.debug(String.format("NODE %d: Command class %s (0x%02x) not found, trying to add it.",
          nodeId, commandClass.getLabel(), commandClass.getKey()));
     
      zwaveCommandClass = ZWaveCommandClass.getInstance(commandClass.getKey(), node, zController);
     
      if (zwaveCommandClass != null) {
        logger.debug(String.format("NODE %d: Adding command class %s (0x%02x)", nodeId, commandClass.getLabel(), commandClass.getKey()));
        node.addCommandClass(zwaveCommandClass);
      }
    }
   
    // We got an unsupported command class, return.
    if (zwaveCommandClass == null) {
View Full Code Here

Examples of org.openhab.binding.zwave.internal.protocol.ZWaveNode

    int nodeId = lastSentMessage.getMessagePayloadByte(0);
   
    logger.debug("NODE {}: Got NodeRoutingInfo request.", nodeId);

    // Get the node
    ZWaveNode node = zController.getNode(nodeId);
    if(node == null) {
      logger.error("NODE {}: Routing information for unknown node", nodeId);
      transactionComplete = true;
      return false;
    }

    node.clearNeighbors();
    boolean hasNeighbors = false;
    for (int by = 0; by < NODE_BYTES; by++) {
      for (int bi = 0; bi < 8; bi++) {
        if ((incomingMessage.getMessagePayloadByte(by) & (0x01 << bi)) != 0) {
          hasNeighbors = true;

          // Add the node to the neighbor list
          node.addNeighbor((by << 3) + bi + 1);
        }
      }
    }

    if (!hasNeighbors) {
      logger.debug("NODE {}: No neighbors reported", nodeId);
    }
    else {
      String neighbors = "Neighbor nodes:";
      for (Integer neighborNode : node.getNeighbors()) {
        neighbors += " " + neighborNode;
      }
      logger.debug("Node {}: {}", nodeId, neighbors);
    }
View Full Code Here

Examples of org.openhab.binding.zwave.internal.protocol.ZWaveNode

   
    switch (updateState) {
    case NODE_INFO_RECEIVED:
      logger.debug("NODE {}: Application update request, node information received.", nodeId);     
      int length = incomingMessage.getMessagePayloadByte(2);
      ZWaveNode node = zController.getNode(nodeId);
     
      node.resetResendCount();

      if(node.getNodeStage() == NodeStage.DONE) {
        // If this node supports associations, then assume this should be handled through that mechanism
        if(node.getCommandClass(CommandClass.ASSOCIATION) == null) {
          // If we receive an Application Update Request and the node is already
          // fully initialised we assume this is a request to the controller to
          // re-get the current node values
          logger.debug("NODE {}: Application update request, requesting node state.", nodeId);

          zController.pollNode(node);
        }
      }
      else {
        for (int i = 6; i < length + 3; i++) {
          int data = incomingMessage.getMessagePayloadByte(i);
          if(data == 0xef)  {
            // TODO: Implement control command classes
            break;
          }
          logger.trace(String.format("NODE %d: Command class 0x%02X is supported.", nodeId, data));
          ZWaveCommandClass commandClass = ZWaveCommandClass.getInstance(data, node, zController);
          if (commandClass != null)
            node.addCommandClass(commandClass);
        }

        // advance node stage.
        node.advanceNodeStage(NodeStage.MANSPEC01);
      }
     
      checkTransactionComplete(lastSentMessage, incomingMessage);

      // Treat the node information frame as a wakeup
      ZWaveWakeUpCommandClass wakeUp = (ZWaveWakeUpCommandClass)node.getCommandClass(ZWaveCommandClass.CommandClass.WAKE_UP);
      if(wakeUp != null) {
        wakeUp.setAwake(true);
      }
      break;
    case NODE_INFO_REQ_FAILED:
View Full Code Here

Examples of org.openhab.binding.zwave.internal.protocol.ZWaveNode

    if (splitDomain[0].equals("nodes")) {
      int nodeId = Integer.parseInt(splitDomain[1].substring(4));

      // Get the node - if it exists
      ZWaveNode node = zController.getNode(nodeId);
      if (node == null) {
        logger.error("NODE {}: Error finding node in doAction", nodeId);
        return;
      }

      if (splitDomain.length == 2) {
        if (action.equals("Heal")) {
          logger.debug("NODE {}: Heal node", nodeId);

          if (networkMonitor != null)
            networkMonitor.healNode(nodeId);
        }

        if (action.equals("Save")) {
          logger.debug("NODE {}: Saving node", nodeId);

          // Write the node to disk
          ZWaveNodeSerializer nodeSerializer = new ZWaveNodeSerializer();
          nodeSerializer.SerializeNode(node);
        }

        if (action.equals("Delete")) {
          logger.debug("NODE {}: Delete node", nodeId);
          this.zController.requestRemoveFailedNode(nodeId);
        }

        // This is temporary
        // It should be in the startup code, but that needs refactoring
        if (action.equals("Version")) {
          logger.debug("NODE {}: Get node version", nodeId);
          ZWaveVersionCommandClass versionCommandClass = (ZWaveVersionCommandClass) node
              .getCommandClass(CommandClass.VERSION);

          if (versionCommandClass == null) {
            logger.error("NODE {}: Error getting versionCommandClass in doAction", nodeId);
            return;
          }

          // Request the version report for this node
          this.zController.sendData(versionCommandClass.getVersionMessage());
        }

        // Return here as afterwards we assume there are more elements
        // in the domain array
        return;
      }

      if (splitDomain[2].equals("parameters")) {
        ZWaveConfigurationCommandClass configurationCommandClass = (ZWaveConfigurationCommandClass) node
            .getCommandClass(CommandClass.CONFIGURATION);

        if (configurationCommandClass == null) {
          logger.error("NODE {}: Error getting configurationCommandClass in doAction", nodeId);
          return;
        }
        if (action.equals("Refresh")) {
          logger.debug("NODE {}: Refresh parameters", nodeId);

          ZWaveProductDatabase database = new ZWaveProductDatabase();
          if (database.FindProduct(node.getManufacturer(), node.getDeviceType(), node.getDeviceId()) == false) {
            logger.error("NODE {}: Error getting parameters - no database found", nodeId);
            return;
          }

          List<ZWaveDbConfigurationParameter> configList = database.getProductConfigParameters();

          // Request all parameters for this node
          for (ZWaveDbConfigurationParameter parameter : configList)
            this.zController.sendData(configurationCommandClass.getConfigMessage(parameter.Index));
        }
      }

      if (splitDomain[2].equals("wakeup")) {
        if (action.equals("Refresh")) {
          logger.debug("NODE {}: Refresh wakeup capabilities", nodeId);

          ZWaveWakeUpCommandClass wakeupCommandClass = (ZWaveWakeUpCommandClass) node
              .getCommandClass(CommandClass.WAKE_UP);

          if (wakeupCommandClass == null) {
            logger.error("NODE {}: Error getting wakeupCommandClass in doAction", nodeId);
            return;
          }

          // Request the wakeup interval for this node
          this.zController.sendData(wakeupCommandClass.getIntervalMessage());

          // Request the wakeup parameters for this node
          this.zController.sendData(wakeupCommandClass.getIntervalCapabilitiesMessage());
        }
      }

      if (splitDomain[2].equals("neighbors")) {
        if (action.equals("Refresh")) {
          // this.zController.requestNodeNeighborUpdate(nodeId);
          this.zController.requestNodeRoutingInfo(nodeId);// .requestNodeNeighborUpdate(nodeId);
        }
      }

      if (splitDomain[2].equals("associations")) {
        if (action.equals("Refresh")) {
          logger.debug("NODE {}: Refresh associations", nodeId);

          ZWaveProductDatabase database = new ZWaveProductDatabase();
          if (database.FindProduct(node.getManufacturer(), node.getDeviceType(), node.getDeviceId()) == false) {
            logger.error("NODE {}: Error in doAction - no database found", nodeId);
            return;
          }

          ZWaveAssociationCommandClass associationCommandClass = (ZWaveAssociationCommandClass) node
              .getCommandClass(CommandClass.ASSOCIATION);
          if (associationCommandClass == null) {
            logger.error("NODE {}: Error getting associationCommandClass in doAction", nodeId);
            return;
          }
View Full Code Here

Examples of org.openhab.binding.zwave.internal.protocol.ZWaveNode

    }

    if (splitDomain[0].equals("nodes")) {
      int nodeId = Integer.parseInt(splitDomain[1].substring(4));

      ZWaveNode node = zController.getNode(nodeId);
      if (node == null) {
        logger.error("Error finding node in doSet '{}'", domain);
        return;
      }

      ZWaveProductDatabase database = new ZWaveProductDatabase();
      if (database.FindProduct(node.getManufacturer(), node.getDeviceType(), node.getDeviceId()) == false) {
        logger.error("NODE {}: Error in doSet - no database found", nodeId);
        return;
      }

      if (splitDomain.length == 3) {
        if (splitDomain[2].equals("Name"))
          node.setName(value);
        if (splitDomain[2].equals("Location"))
          node.setLocation(value);
       
        // Write the node to disk
        ZWaveNodeSerializer nodeSerializer = new ZWaveNodeSerializer();
        nodeSerializer.SerializeNode(node);
      } else if (splitDomain.length == 4) {
        if (splitDomain[2].equals("parameters")) {
          ZWaveConfigurationCommandClass configurationCommandClass = (ZWaveConfigurationCommandClass) node
              .getCommandClass(CommandClass.CONFIGURATION);

          if (configurationCommandClass == null) {
            logger.error("NODE {}: Error getting configurationCommandClass in doSet", nodeId);
            return;
          }

          int paramIndex = Integer.parseInt(splitDomain[3].substring(13));
          List<ZWaveDbConfigurationParameter> configList = database.getProductConfigParameters();

          // Get the size
          int size = 1;
          for (ZWaveDbConfigurationParameter parameter : configList) {
            if (parameter.Index == paramIndex) {
              size = parameter.Size;
              break;
            }
          }

          logger.debug("Set parameter index '{}' to '{}'", paramIndex, value);

          PendingCfg.Add(ZWaveCommandClass.CommandClass.CONFIGURATION.getKey(), nodeId, paramIndex, Integer.valueOf(value));

          ConfigurationParameter configurationParameter = new ConfigurationParameter(paramIndex,
              Integer.valueOf(value), size);
          // Set the parameter
          this.zController.sendData(configurationCommandClass.setConfigMessage(configurationParameter));
          // And request a read-back
          this.zController.sendData(configurationCommandClass.getConfigMessage(paramIndex));
        }
        if (splitDomain[2].equals("wakeup")) {
          ZWaveWakeUpCommandClass wakeupCommandClass = (ZWaveWakeUpCommandClass) node
              .getCommandClass(CommandClass.WAKE_UP);

          if (wakeupCommandClass == null) {
            logger.error("NODE {}: Error getting wakeupCommandClass in doSet", nodeId);
            return;
          }
         
          logger.debug("NODE {}: Set wakeup interval to '{}'", nodeId, value);

          // Add this as a pending transaction
          PendingCfg.Add(ZWaveCommandClass.CommandClass.WAKE_UP.getKey(), node.getNodeId(), Integer.parseInt(value));

          // Set the wake-up interval
          this.zController.sendData(wakeupCommandClass.setInterval(Integer.parseInt(value)));
          // And request a read-back
          this.zController.sendData(wakeupCommandClass.getIntervalMessage());
        }
        if (splitDomain[2].equals("controller")) {
          if(splitDomain[3].equals("Type")) {
            ZWaveDeviceType type = ZWaveDeviceType.fromString(value);
            logger.error("NODE {}: Setting controller type to {}", nodeId, type.toString());
//            ZW_EnableSUC and ZW_SetSUCNodeID
          }

        }
      } else if (splitDomain.length == 5) {
        if (splitDomain[2].equals("associations")) {
          ZWaveAssociationCommandClass associationCommandClass = (ZWaveAssociationCommandClass) node
              .getCommandClass(CommandClass.ASSOCIATION);
          if (associationCommandClass == null) {
            logger.error("NODE {}: Error getting associationCommandClass in doSet", nodeId);
            return;
          }
View Full Code Here

Examples of org.openhab.binding.zwave.internal.protocol.ZWaveNode

   
    // this binding is configured not to poll.
    if (!forceRefresh && bindingConfiguration.getRefreshInterval() != null && 0 == bindingConfiguration.getRefreshInterval())
      return;
   
    ZWaveNode node = this.controller.getNode(bindingConfiguration.getNodeId());
   
    // ignore nodes that are not initialized.
    if (node == null)
      return;
   
    if (commandClassName != null) {
     
      // this is a report item, handle it with the report info converter.
      if (commandClassName.equalsIgnoreCase("info")) {
        infoConverter.executeRefresh(provider.getItem(itemName), node, bindingConfiguration.getEndpoint(), bindingConfiguration.getArguments());
        return;
      }
     
      // ignore nodes that are not initialized or dead.
      if (node.getNodeStage() != NodeStage.DONE)
        return;
     
      commandClass = node.resolveCommandClass(CommandClass.getCommandClass(commandClassName), bindingConfiguration.getEndpoint());
     
      if (commandClass == null) {
         logger.warn("No command class found for item = {}, command class name = {}, ignoring execute refresh.", itemName, commandClassName);
         return;
      }
View Full Code Here

Examples of org.openhab.binding.zwave.internal.protocol.ZWaveNode

    // this binding is configured not to poll.
    if (bindingConfiguration.getRefreshInterval() != null && 0 == bindingConfiguration.getRefreshInterval())
      return 0;

    ZWaveNode node = this.controller.getNode(bindingConfiguration.getNodeId());

    // ignore nodes that are not initialized.
    if (node == null)
      return 0;

    if (commandClassName != null) {
      // this is a report item, handle it with the report info converter.
      if (commandClassName.equalsIgnoreCase("info")) {
        return infoConverter.getRefreshInterval();
      }

      commandClass = node.resolveCommandClass(CommandClass.getCommandClass(commandClassName),
          bindingConfiguration.getEndpoint());

      if (commandClass == null) {
        logger.warn("No command class found for item = {}, command class name = {}, using 0 refresh interval.",
            itemName, commandClassName);
View Full Code Here

Examples of org.openhab.binding.zwave.internal.protocol.ZWaveNode

   * @param command the received {@link Command}
   */
  @SuppressWarnings("unchecked")
  public void receiveCommand(ZWaveBindingProvider provider, String itemName, Command command) {
    ZWaveBindingConfig bindingConfiguration = provider.getZwaveBindingConfig(itemName);
    ZWaveNode node = this.controller.getNode(bindingConfiguration.getNodeId());
    if(node == null) {
      logger.error("Item {} has non existant node {}", itemName, bindingConfiguration.getNodeId());
      return;
    }
    ZWaveCommandClass commandClass;
    String commandClassName = bindingConfiguration.getArguments().get("command");
   
    if (commandClassName != null) {
      commandClass = node.resolveCommandClass(CommandClass.getCommandClass(commandClassName), bindingConfiguration.getEndpoint());
     
      if (commandClass == null) {
         logger.warn("No command class found for item = {}, command class name = {}, ignoring command.", itemName, commandClassName);
         return;
      }
View Full Code Here

Examples of org.openhab.binding.zwave.internal.protocol.ZWaveNode

            int seconds = serialMessage.getMessagePayloadByte(offset++);
            logger.debug("NODE {}: is busy and wants us to try again in {} seconds",getNode(), seconds);
            retry = seconds * 1000;
          case StatusBusyTryAgainLater:
            logger.debug("NODE {}: is busy and wants us to try again later", getNode());
            final ZWaveNode node = this.getNode();
            final ZWaveController controller = this.getController();
            scheduler.schedule(new Runnable() {
              @Override
              public void run() {
                if (node== null || node.getNodeStage() != NodeStage.DONE)
                  return;
                controller.pollNode(node);
               
              }
            }, retry, TimeUnit.MILLISECONDS);
View Full Code Here

Examples of org.openhab.binding.zwave.internal.protocol.ZWaveNode

      return false;
    }

    switch (status) {
    case COMPLETE_OK:
      ZWaveNode node = zController.getNode(originalMessage.getMessageNode());
      if(node == null)
        break;
     
      // Consider this as a received frame since the controller did receive an ACK from the device.
      node.incrementReceiveCount();

      // If the node is DEAD, but we've just received a message from it, then it's not dead!
      if(node.isDead()) {
        node.setAlive();
        logger.debug("NODE {}: Node has risen from the DEAD. Set stage to {}.", node.getNodeId(), node.getNodeStage());     
      }
      else {
        node.resetResendCount();
        // in case we received a ping response and the node is alive, we
        // proceed with the next node stage for this node.
        if (node.getNodeStage() == NodeStage.PING) {
          node.advanceNodeStage(NodeStage.DETAILS);
        }
      }
      checkTransactionComplete(lastSentMessage, incomingMessage);
      return true;
    case COMPLETE_NO_ACK:
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.