mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[amazonechocontrol] Support QuantityType Color Temperature command (#17919)
* [various] process color temperature quantity type commands Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch> Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
parent
ff8d95a420
commit
1c26aea3a0
@ -26,7 +26,9 @@ import org.openhab.binding.amazonechocontrol.internal.handler.SmartHomeDeviceHan
|
||||
import org.openhab.binding.amazonechocontrol.internal.jsons.JsonSmartHomeCapabilities.SmartHomeCapability;
|
||||
import org.openhab.binding.amazonechocontrol.internal.jsons.JsonSmartHomeDevices.SmartHomeDevice;
|
||||
import org.openhab.core.library.types.DecimalType;
|
||||
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.DefaultSystemChannelTypeProvider;
|
||||
import org.openhab.core.thing.type.ChannelTypeUID;
|
||||
import org.openhab.core.types.Command;
|
||||
@ -130,15 +132,21 @@ public class HandlerColorTemperatureController extends HandlerBase {
|
||||
if (channelId.equals(COLOR_TEMPERATURE_IN_KELVIN.channelId)) {
|
||||
// WRITING TO THIS CHANNEL DOES CURRENTLY NOT WORK, BUT WE LEAVE THE CODE FOR FUTURE USE!
|
||||
if (containsCapabilityProperty(capabilities, COLOR_TEMPERATURE_IN_KELVIN.propertyName)) {
|
||||
if (command instanceof DecimalType) {
|
||||
int intValue = ((DecimalType) command).intValue();
|
||||
if (intValue < 1000) {
|
||||
intValue = 1000;
|
||||
QuantityType<?> kelvinQuantity = null;
|
||||
if (command instanceof QuantityType<?> genericQuantity) {
|
||||
kelvinQuantity = genericQuantity.toInvertibleUnit(Units.KELVIN);
|
||||
} else if (command instanceof DecimalType decimal) {
|
||||
kelvinQuantity = QuantityType.valueOf(decimal.intValue(), Units.KELVIN);
|
||||
}
|
||||
if (intValue > 10000) {
|
||||
intValue = 10000;
|
||||
if (kelvinQuantity != null) {
|
||||
int kelvin = kelvinQuantity.intValue();
|
||||
if (kelvin < 1000) {
|
||||
kelvin = 1000;
|
||||
}
|
||||
connection.smartHomeCommand(entityId, "setColorTemperature", "colorTemperatureInKelvin", intValue);
|
||||
if (kelvin > 10000) {
|
||||
kelvin = 10000;
|
||||
}
|
||||
connection.smartHomeCommand(entityId, "setColorTemperature", "colorTemperatureInKelvin", kelvin);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user