/** {@inheritDoc} */
  @Override
  public List<SerialMessage> receiveCommand(
      ZWaveThingChannel channel, ZWaveNode node, Command command) {
    // Is this channel a reset button - if not, just return
    if ("true".equalsIgnoreCase(channel.getArguments().get("reset")) == false) {
      return null;
    }

    // It's not an ON command from a button switch, do not reset
    if (command != OnOffType.ON) {
      return null;
    }

    ZWaveMeterCommandClass commandClass =
        (ZWaveMeterCommandClass)
            node.resolveCommandClass(ZWaveCommandClass.CommandClass.METER, channel.getEndpoint());

    // Get the reset message - will return null if not supported
    SerialMessage serialMessage =
        node.encapsulate(commandClass.getResetMessage(), commandClass, channel.getEndpoint());

    if (serialMessage == null) {
      return null;
    }

    // Queue reset message
    List<SerialMessage> messages = new ArrayList<SerialMessage>();
    messages.add(serialMessage);

    // And poll the device
    for (SerialMessage serialGetMessage : commandClass.getDynamicValues(true)) {
      messages.add(node.encapsulate(serialGetMessage, commandClass, channel.getEndpoint()));
    }
    return messages;
  }
Exemplo n.º 2
0
  /** {@inheritDoc} */
  @Override
  public void receiveCommand(
      Item item,
      Command command,
      ZWaveNode node,
      ZWaveMeterCommandClass commandClass,
      int endpointId,
      Map<String, String> arguments) {

    // It's not an ON command from a button switch, do not reset
    if (command != OnOffType.ON) {
      return;
    }

    // get the reset message - will return null if not supported
    SerialMessage serialMessage =
        node.encapsulate(commandClass.getResetMessage(), commandClass, endpointId);

    if (serialMessage == null) {
      logger.warn(
          "NODE {}: Meter reset not supported for item = {}, endpoint = {}, ignoring event.",
          node.getNodeId(),
          item.getName(),
          endpointId);
      return;
    }

    // send reset message
    this.getController().sendData(serialMessage);

    // poll the device
    for (SerialMessage serialGetMessage : commandClass.getDynamicValues(true)) {
      this.getController().sendData(node.encapsulate(serialGetMessage, commandClass, endpointId));
    }
  }
  /** {@inheritDoc} */
  @Override
  public List<SerialMessage> executeRefresh(ZWaveThingChannel channel, ZWaveNode node) {
    ZWaveMeterCommandClass commandClass =
        (ZWaveMeterCommandClass)
            node.resolveCommandClass(ZWaveCommandClass.CommandClass.METER, channel.getEndpoint());
    if (commandClass == null) {
      return null;
    }

    logger.debug(
        "NODE {}: Generating poll message for {}, endpoint {}",
        node.getNodeId(),
        commandClass.getCommandClass().getLabel(),
        channel.getEndpoint());
    SerialMessage serialMessage;

    // Don't refresh channels that are the reset button
    if ("true".equalsIgnoreCase(channel.getArguments().get("reset"))) {
      return null;
    }

    String meterScale = channel.getArguments().get("type");
    logger.debug(
        "NODE {}: Generating poll message for {}, endpoint {}",
        node.getNodeId(),
        commandClass.getCommandClass().getLabel(),
        channel.getEndpoint());

    if (meterScale != null) {
      serialMessage =
          node.encapsulate(
              commandClass.getMessage(MeterScale.getMeterScale(meterScale)),
              commandClass,
              channel.getEndpoint());
    } else {
      serialMessage =
          node.encapsulate(commandClass.getValueMessage(), commandClass, channel.getEndpoint());
    }

    List<SerialMessage> response = new ArrayList<SerialMessage>(1);
    response.add(serialMessage);
    return response;
  }
Exemplo n.º 4
0
  /** {@inheritDoc} */
  @Override
  public SerialMessage executeRefresh(
      ZWaveNode node,
      ZWaveMeterCommandClass commandClass,
      int endpointId,
      Map<String, String> arguments) {
    String meterScale = arguments.get("meter_scale");

    logger.debug(
        "NODE {}: Generating poll message for {}, endpoint {}",
        node.getNodeId(),
        commandClass.getCommandClass().getLabel(),
        endpointId);

    if (meterScale != null) {
      return node.encapsulate(
          commandClass.getMessage(MeterScale.getMeterScale(meterScale)), commandClass, endpointId);
    } else {
      return node.encapsulate(commandClass.getValueMessage(), commandClass, endpointId);
    }
  }