diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/QuantityType.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/QuantityType.java index 3a6a9521a..779bdfcd6 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/QuantityType.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/QuantityType.java @@ -338,6 +338,15 @@ public class QuantityType> extends Number return new QuantityType<>(result.getValue(), targetUnit); } + public @Nullable QuantityType toUnitRelative(String targetUnit) { + Unit unit = (Unit) AbstractUnit.parse(targetUnit); + if (unit != null) { + return toUnitRelative(unit); + } + + return null; + } + public BigDecimal toBigDecimal() { return new BigDecimal(quantity.getValue().toString()); }