mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[deconz] support QuantityType commands (#17942)
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
This commit is contained in:
parent
a100c27323
commit
e84a582d87
@ -14,7 +14,6 @@ package org.openhab.binding.deconz.internal.handler;
|
||||
|
||||
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.DecimalType;
|
||||
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 class GroupThingHandler extends DeconzBaseThingHandler {
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -245,9 +245,15 @@ public class LightThingHandler extends DeconzBaseThingHandler {
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user