/** {@inheritDoc} */ @Override public State handleEvent(ZWaveThingChannel channel, ZWaveCommandClassValueEvent event) { // We ignore any meter reports for item bindings configured with 'reset=true' // since we don't want to be updating the 'reset' switch if ("true".equalsIgnoreCase(channel.getArguments().get("reset"))) { return null; } String meterScale = channel.getArguments().get("type"); String meterZero = channel.getArguments().get("zero"); // needs to be a config setting - not arg ZWaveMeterValueEvent meterEvent = (ZWaveMeterValueEvent) event; // logger.debug("Meter converter: scale {} <> {}", meterScale, meterEvent.getMeterScale()); // Don't trigger event if this item is bound to another sensor type if (meterScale != null && MeterScale.getMeterScale(meterScale) != meterEvent.getMeterScale()) { logger.debug("Not the right scale {} <> {}", meterScale, meterEvent.getMeterScale()); return null; } BigDecimal val = (BigDecimal) event.getValue(); // If we've set a zero, then anything below this value needs to be considered ZERO if (meterZero != null) { if (val.doubleValue() <= Double.parseDouble(meterZero)) { val = BigDecimal.ZERO; } } return new DecimalType(val); }
/** {@inheritDoc} */ @Override void handleEvent(ZWaveCommandClassValueEvent event, Item item, Map<String, String> arguments) { ZWaveStateConverter<?, ?> converter = this.getStateConverter(item, event.getValue()); if (converter == null) { logger.warn( "NODE {}: No converter found for item = {}, endpoint = {}, ignoring event.", event.getNodeId(), item.getName(), event.getEndpoint()); return; } State state = converter.convertFromValueToState(event.getValue()); this.getEventPublisher().postUpdate(item.getName(), state); }
/** {@inheritDoc} */ @Override public void handleEvent( ZWaveCommandClassValueEvent event, Item item, Map<String, String> arguments) { ZWaveStateConverter<?, ?> converter = this.getStateConverter(item, event.getValue()); if (converter == null) { logger.warn( "NODE {}: No converter found for item = {}, endpoint = {}, ignoring event.", event.getNodeId(), item.getName(), event.getEndpoint()); return; } // we ignore any meter reports for item bindings configured with 'meter_reset=true' // since we don't want to be updating the 'reset' switch if ("true".equalsIgnoreCase(arguments.get("meter_reset"))) { return; } String meterScale = arguments.get("meter_scale"); String meterZero = arguments.get("meter_zero"); ZWaveMeterValueEvent meterEvent = (ZWaveMeterValueEvent) event; // Don't trigger event if this item is bound to another sensor type if (meterScale != null && MeterScale.getMeterScale(meterScale) != meterEvent.getMeterScale()) { return; } Object val = event.getValue(); // If we've set a zero, then anything below this value needs to be considered ZERO if (meterZero != null) { if (((BigDecimal) val).doubleValue() <= Double.parseDouble(meterZero)) { val = BigDecimal.ZERO; } } State state = converter.convertFromValueToState(val); this.getEventPublisher().postUpdate(item.getName(), state); }