mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[shelly] support QuantityType commands (#17947)
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
This commit is contained in:
parent
56d447fa77
commit
da6dde5cad
@ -38,6 +38,7 @@ import org.openhab.core.library.types.HSBType;
|
|||||||
import org.openhab.core.library.types.IncreaseDecreaseType;
|
import org.openhab.core.library.types.IncreaseDecreaseType;
|
||||||
import org.openhab.core.library.types.OnOffType;
|
import org.openhab.core.library.types.OnOffType;
|
||||||
import org.openhab.core.library.types.PercentType;
|
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.types.StringType;
|
||||||
import org.openhab.core.library.unit.Units;
|
import org.openhab.core.library.unit.Units;
|
||||||
import org.openhab.core.thing.ChannelUID;
|
import org.openhab.core.thing.ChannelUID;
|
||||||
@ -187,6 +188,12 @@ public class ShellyLightHandler extends ShellyBaseHandler {
|
|||||||
} else if (command instanceof DecimalType decimalCommand) {
|
} else if (command instanceof DecimalType decimalCommand) {
|
||||||
temp = decimalCommand.intValue();
|
temp = decimalCommand.intValue();
|
||||||
logger.debug("{}: Set color temp to {}K (Integer)", thingName, temp);
|
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);
|
validateRange(CHANNEL_COLOR_TEMP, temp, col.minTemp, col.maxTemp);
|
||||||
col.setTemp(temp);
|
col.setTemp(temp);
|
||||||
|
Loading…
Reference in New Issue
Block a user