mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-25 14:55:55 +01:00
[deconz] support QuantityType commands (#17942)
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
This commit is contained in:
parent
6e6a0d080c
commit
c48752e6e1
@ -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.BindingConstants.*;
|
||||||
import static org.openhab.binding.deconz.internal.Util.constrainToRange;
|
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.Collection;
|
||||||
import java.util.Map;
|
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.HSBType;
|
||||||
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.thing.Channel;
|
import org.openhab.core.thing.Channel;
|
||||||
import org.openhab.core.thing.ChannelUID;
|
import org.openhab.core.thing.ChannelUID;
|
||||||
import org.openhab.core.thing.Thing;
|
import org.openhab.core.thing.Thing;
|
||||||
@ -139,9 +140,15 @@ public class GroupThingHandler extends DeconzBaseThingHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case CHANNEL_COLOR_TEMPERATURE -> {
|
case CHANNEL_COLOR_TEMPERATURE -> {
|
||||||
if (command instanceof DecimalType decimalCommand) {
|
QuantityType<?> miredQuantity = null;
|
||||||
int miredValue = kelvinToMired(decimalCommand.intValue());
|
if (command instanceof QuantityType<?> genericQuantity) {
|
||||||
newGroupAction.ct = constrainToRange(miredValue, ZCL_CT_MIN, ZCL_CT_MAX);
|
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;
|
newGroupAction.on = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -245,9 +245,15 @@ public class LightThingHandler extends DeconzBaseThingHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case CHANNEL_COLOR_TEMPERATURE -> {
|
case CHANNEL_COLOR_TEMPERATURE -> {
|
||||||
if (command instanceof DecimalType) {
|
QuantityType<?> miredQuantity = null;
|
||||||
int miredValue = kelvinToMired(((DecimalType) command).intValue());
|
if (command instanceof QuantityType<?> genericQuantity) {
|
||||||
newLightState.ct = constrainToRange(miredValue, ctMin, ctMax);
|
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;
|
newLightState.on = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user