@Override public State convertToState(RFXComValueSelector valueSelector) throws RFXComException { org.openhab.core.types.State state = UnDefType.UNDEF; if (valueSelector.getItemClass() == NumberItem.class) { if (valueSelector == RFXComValueSelector.SIGNAL_LEVEL) { state = new DecimalType(signalLevel); } else if (valueSelector == RFXComValueSelector.BATTERY_LEVEL) { state = new DecimalType(batteryLevel); } else { throw new RFXComException("Can't convert " + valueSelector + " to NumberItem"); } } else if (valueSelector.getItemClass() == RollershutterItem.class) { if (valueSelector == RFXComValueSelector.COMMAND) { switch (command) { case CLOSE: state = OpenClosedType.CLOSED; break; case OPEN: state = OpenClosedType.OPEN; break; default: break; } } else { throw new NumberFormatException("Can't convert " + valueSelector + " to RollershutterItem"); } } else if (valueSelector.getItemClass() == StringItem.class) { if (valueSelector == RFXComValueSelector.RAW_DATA) { state = new StringType(DatatypeConverter.printHexBinary(rawMessage)); } else { throw new NumberFormatException("Can't convert " + valueSelector + " to StringItem"); } } else { throw new NumberFormatException( "Can't convert " + valueSelector + " to " + valueSelector.getItemClass()); } return state; }
@Override public State convertToState(RFXComValueSelector valueSelector) throws RFXComException { org.openhab.core.types.State state = UnDefType.UNDEF; if (valueSelector.getItemClass() == NumberItem.class) { if (valueSelector == RFXComValueSelector.SIGNAL_LEVEL) { state = new DecimalType(signalLevel); } else if (valueSelector == RFXComValueSelector.BATTERY_LEVEL) { state = new DecimalType(batteryLevel); } else if (valueSelector == RFXComValueSelector.CHANNEL1_AMPS) { state = new DecimalType(channel1Amps); } else if (valueSelector == RFXComValueSelector.CHANNEL2_AMPS) { state = new DecimalType(channel2Amps); } else if (valueSelector == RFXComValueSelector.CHANNEL3_AMPS) { state = new DecimalType(channel3Amps); } else if (valueSelector == RFXComValueSelector.TOTAL_USAGE) { state = new DecimalType(totalUsage); } else { throw new RFXComException("Can't convert " + valueSelector + " to NumberItem"); } } else if (valueSelector.getItemClass() == StringItem.class) { if (valueSelector == RFXComValueSelector.RAW_DATA) { state = new StringType(DatatypeConverter.printHexBinary(rawMessage)); } else { throw new RFXComException("Can't convert " + valueSelector + " to StringItem"); } } else { throw new RFXComException( "Can't convert " + valueSelector + " to " + valueSelector.getItemClass()); } return state; }
@Override public State convertToState(RFXComValueSelector valueSelector) throws RFXComException { org.openhab.core.types.State state = UnDefType.UNDEF; if (valueSelector.getItemClass() == StringItem.class) { if (valueSelector == RFXComValueSelector.RAW_DATA) { state = new StringType(DatatypeConverter.printHexBinary(rawMessage)); } else if (valueSelector == RFXComValueSelector.DATA) { state = new StringType(DatatypeConverter.printHexBinary(rawData)); } else { throw new RFXComException("Can't convert " + valueSelector + " to StringItem"); } } else { throw new RFXComException( "Can't convert " + valueSelector + " to " + valueSelector.getItemClass()); } return state; }