/** {@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; }
/** {@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)); } }