Source:
private Type applyOffset(Type state, boolean towardsItem) { QuantityType finalOffset = offset; if (finalOffset == null) { logger.error( "Offset not configured correctly, please make sure it is of type QuantityType, e.g. \"3\", \"-1.4\", \"3.2°C\". Using offset 0 now."); return new QuantityType<Dimensionless>("0"); } if (!towardsItem) { finalOffset = finalOffset.negate(); } Type result = UnDefType.UNDEF; if (state instanceof QuantityType) { QuantityType qtState = (QuantityType) state; try { if (finalOffset.getUnit() == SmartHomeUnits.ONE) { finalOffset = new QuantityType<>(finalOffset.toBigDecimal(), qtState.getUnit()); logger.warn( "Received a QuantityType state '{}' with unit, but the offset is defined as a plain number without unit ({}), please consider adding a unit to the profile offset.", state, offset); } if (qtState.getUnit().getSystemUnit().equals(SmartHomeUnits.KELVIN)) { QuantityType<Temperature> tmp = handleTemperature(qtState, finalOffset); if (tmp != null) { result = tmp; } } else { result = qtState.add(finalOffset); } } catch (UnconvertibleException e) { logger.warn("Cannot apply offset '{}' to state '{}' because types do not match.", finalOffset, qtState); } } else if (state instanceof DecimalType && finalOffset.getUnit().equals(SmartHomeUnits.ONE)) { DecimalType decState = (DecimalType) state; result = new DecimalType(decState.doubleValue() + finalOffset.doubleValue()); } else { logger.warn( "Offset '{}' cannot be applied to the incompatible state '{}' sent from the binding. Returning original state.", offset, state); result = state; } return result; }

Target:
private Type applyOffset(Type state, boolean towardsItem) { QuantityType finalOffset = offset; if (finalOffset == null) { logger.warn( "Offset not configured correctly, please make sure it is of type QuantityType, e.g. \"3\", \"-1.4\", \"3.2°C\". Using offset 0 now."); finalOffset = new QuantityType<Dimensionless>("0"); } if (!towardsItem) { finalOffset = finalOffset.negate(); } Type result = UnDefType.UNDEF; if (state instanceof QuantityType) { QuantityType qtState = (QuantityType) state; try { if (finalOffset.getUnit() == SmartHomeUnits.ONE) { finalOffset = new QuantityType<>(finalOffset.toBigDecimal(), qtState.getUnit()); logger.warn( "Received a QuantityType state '{}' with unit, but the offset is defined as a plain number without unit ({}), please consider adding a unit to the profile offset.", state, offset); } if (qtState.getUnit().getSystemUnit().equals(SmartHomeUnits.KELVIN)) { QuantityType<Temperature> tmp = handleTemperature(qtState, finalOffset); if (tmp != null) { result = tmp; } } else { result = qtState.add(finalOffset); } } catch (UnconvertibleException e) { logger.warn("Cannot apply offset '{}' to state '{}' because types do not match.", finalOffset, qtState); } } else if (state instanceof DecimalType && finalOffset.getUnit().equals(SmartHomeUnits.ONE)) { DecimalType decState = (DecimalType) state; result = new DecimalType(decState.doubleValue() + finalOffset.doubleValue()); } else { logger.warn( "Offset '{}' cannot be applied to the incompatible state '{}' sent from the binding. Returning original state.", offset, state); result = state; } return result; }