コード例 #1
0
  /** {@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);
  }
コード例 #2
0
  /** {@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);
  }