Skip to content

Commit

Permalink
[shelly] support QuantityType commands (#17947)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Fiddian-Green <[email protected]>
  • Loading branch information
andrewfg authored Dec 21, 2024
1 parent 56d447f commit da6dde5
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit da6dde5

Please sign in to comment.