[deconz] fix colorlight not updating color channel (#9351)

Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
This commit is contained in:
J-N-K 2020-12-13 16:21:15 +01:00 committed by GitHub
parent c541776f7d
commit b5e13041dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 37 additions and 4 deletions

View File

@ -89,6 +89,10 @@ The transition time is the time to move between two states and is configured in
The resolution provided is 1/10s.
If no value is provided, the default value of the device is used.
`extendedcolorlight` and `colorlight` have different modes for setting the color.
Some devices accept only XY, others HSB, others both modes and the binding tries to autodetect the correct mode.
If this fails, the advanced `colormode` parameter can be set to `xy` or `hs`.
### Textual Thing Configuration - Retrieving an API Key
If you use the textual configuration, the thing file without an API key will look like this, for example:

View File

@ -78,6 +78,7 @@ public class LightThingHandler extends DeconzBaseThingHandler {
*/
private LightState lightStateCache = new LightState();
private LightState lastCommand = new LightState();
private String colorMode = "";
// set defaults, we can override them later if we receive better values
private int ctMax = ZCL_CT_MAX;
@ -179,7 +180,7 @@ public class LightThingHandler extends DeconzBaseThingHandler {
}
} else if (command instanceof HSBType) {
HSBType hsbCommand = (HSBType) command;
if ("xy".equals(lightStateCache.colormode)) {
if ("xy".equals(colorMode)) {
PercentType[] xy = hsbCommand.toXY();
if (xy.length < 2) {
logger.warn("Failed to convert {} to xy-values", command);
@ -268,6 +269,7 @@ public class LightThingHandler extends DeconzBaseThingHandler {
}
LightMessage lightMessage = (LightMessage) stateResponse;
if (needsPropertyUpdate) {
// if we did not receive an ctmin/ctmax, then we probably don't need it
needsPropertyUpdate = false;
@ -427,6 +429,13 @@ public class LightThingHandler extends DeconzBaseThingHandler {
logger.trace("Ignoring differing update after last command until {}", lastCommandExpireTimestamp);
return;
}
if (colorMode.isEmpty()) {
String cmode = lightState.colormode;
if (cmode != null && ("hs".equals(cmode) || "xy".equals(cmode))) {
// only set the color mode if it is hs or xy, not ct
colorMode = cmode;
}
}
lightStateCache = lightState;
if (Boolean.TRUE.equals(lightState.reachable)) {
updateStatus(ThingStatus.ONLINE);

View File

@ -25,4 +25,5 @@ public class ThingConfig {
public String id = "";
public int lastSeenPolling = 1440;
public @Nullable Double transitiontime;
public String colormode = "";
}

View File

@ -47,7 +47,6 @@
</parameter>
</config-description>
<config-description uri="thing-type:deconz:light">
<parameter name="id" type="text" required="true">
<label>Device ID</label>
@ -59,4 +58,24 @@
</parameter>
</config-description>
<config-description uri="thing-type:deconz:colorlight">
<parameter name="id" type="text" required="true">
<label>Device ID</label>
<description>The deCONZ bridge assigns an integer number ID to each device.</description>
</parameter>
<parameter name="transitiontime" type="decimal" required="false" min="0" unit="s">
<label>Transition Time</label>
<description>Time to move between two states. If empty, the default of the device is used. Resolution is 1/10 second.</description>
</parameter>
<parameter name="colormode" type="text" required="false">
<label>Color Mode</label>
<description>Override the default color mode (auto-detect)</description>
<options>
<option value="hs">HSB</option>
<option value="xy">XY</option>
</options>
<advanced>true</advanced>
</parameter>
</config-description>
</config-description:config-descriptions>

View File

@ -97,7 +97,7 @@
<representation-property>uid</representation-property>
<config-description-ref uri="thing-type:deconz:light"/>
<config-description-ref uri="thing-type:deconz:colorlight"/>
</thing-type>
<thing-type id="extendedcolorlight">
@ -114,7 +114,7 @@
<representation-property>uid</representation-property>
<config-description-ref uri="thing-type:deconz:light"/>
<config-description-ref uri="thing-type:deconz:colorlight"/>
</thing-type>
<thing-type id="doorlock">