diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/GroupThingHandler.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/GroupThingHandler.java index 1d3c85b0e3472..62f9977ca40e0 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/GroupThingHandler.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/GroupThingHandler.java @@ -14,7 +14,6 @@ import static org.openhab.binding.deconz.internal.BindingConstants.*; import static org.openhab.binding.deconz.internal.Util.constrainToRange; -import static org.openhab.binding.deconz.internal.Util.kelvinToMired; import java.util.Collection; import java.util.Map; @@ -36,7 +35,9 @@ import org.openhab.core.library.types.HSBType; import org.openhab.core.library.types.OnOffType; import org.openhab.core.library.types.PercentType; +import org.openhab.core.library.types.QuantityType; import org.openhab.core.library.types.StringType; +import org.openhab.core.library.unit.Units; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ChannelUID; import org.openhab.core.thing.Thing; @@ -139,9 +140,15 @@ public void handleCommand(ChannelUID channelUID, Command command) { } } case CHANNEL_COLOR_TEMPERATURE -> { - if (command instanceof DecimalType decimalCommand) { - int miredValue = kelvinToMired(decimalCommand.intValue()); - newGroupAction.ct = constrainToRange(miredValue, ZCL_CT_MIN, ZCL_CT_MAX); + QuantityType miredQuantity = null; + if (command instanceof QuantityType genericQuantity) { + miredQuantity = genericQuantity.toInvertibleUnit(Units.MIRED); + } else if (command instanceof DecimalType decimal) { + miredQuantity = QuantityType.valueOf(decimal.intValue(), Units.KELVIN) + .toInvertibleUnit(Units.MIRED); + } + if (miredQuantity != null) { + newGroupAction.ct = constrainToRange(miredQuantity.intValue(), ZCL_CT_MIN, ZCL_CT_MAX); newGroupAction.on = true; } } diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java index 2e035dd1374d8..58c0e24eea2ab 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java @@ -245,9 +245,15 @@ public void handleCommand(ChannelUID channelUID, Command command) { } } case CHANNEL_COLOR_TEMPERATURE -> { - if (command instanceof DecimalType) { - int miredValue = kelvinToMired(((DecimalType) command).intValue()); - newLightState.ct = constrainToRange(miredValue, ctMin, ctMax); + QuantityType miredQuantity = null; + if (command instanceof QuantityType genericQuantity) { + miredQuantity = genericQuantity.toInvertibleUnit(Units.MIRED); + } else if (command instanceof DecimalType decimal) { + miredQuantity = QuantityType.valueOf(decimal.intValue(), Units.KELVIN) + .toInvertibleUnit(Units.MIRED); + } + if (miredQuantity != null) { + newLightState.ct = constrainToRange(miredQuantity.intValue(), ctMin, ctMax); newLightState.on = true; } }