From 79348a30a02e18e0e7dc2bc0234d4da3c256e5f2 Mon Sep 17 00:00:00 2001 From: Andrew Fiddian-Green Date: Sat, 21 Dec 2024 11:18:22 +0000 Subject: [PATCH] [shelly] support QuantityType commands (#17947) Signed-off-by: Andrew Fiddian-Green --- .../shelly/internal/handler/ShellyLightHandler.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyLightHandler.java b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyLightHandler.java index b80fc161cb5c9..279efffffa21f 100644 --- a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyLightHandler.java +++ b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyLightHandler.java @@ -38,6 +38,7 @@ import org.openhab.core.library.types.IncreaseDecreaseType; 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.ChannelUID; @@ -187,6 +188,12 @@ public boolean handleDeviceCommand(ChannelUID channelUID, Command command) throw } else if (command instanceof DecimalType decimalCommand) { temp = decimalCommand.intValue(); logger.debug("{}: Set color temp to {}K (Integer)", thingName, temp); + } else if (command instanceof QuantityType genericQuantity) { + QuantityType kelvinQuantity = genericQuantity.toInvertibleUnit(Units.KELVIN); + if (kelvinQuantity != null) { + temp = kelvinQuantity.intValue(); + logger.debug("{}: Set color temp to {}K (Integer)", thingName, temp); + } } validateRange(CHANNEL_COLOR_TEMP, temp, col.minTemp, col.maxTemp); col.setTemp(temp);