]> git.basschouten.com Git - openhab-addons.git/commitdiff
[deconz] fix colorlight not updating color channel (#9351)
authorJ-N-K <J-N-K@users.noreply.github.com>
Sun, 13 Dec 2020 15:21:15 +0000 (16:21 +0100)
committerGitHub <noreply@github.com>
Sun, 13 Dec 2020 15:21:15 +0000 (16:21 +0100)
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
bundles/org.openhab.binding.deconz/README.md
bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java
bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/ThingConfig.java
bundles/org.openhab.binding.deconz/src/main/resources/OH-INF/config/config.xml
bundles/org.openhab.binding.deconz/src/main/resources/OH-INF/thing/light-thing-types.xml

index e2ef2c1f984dfcc6c1a13c38357fda26c088a5a3..62d56d096e93460a781e3238c1b68c1370d4239f 100644 (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:
index 8dfe010cab2c8347d25dc4ceafdf1ccfc19c59e5..fcacb90fcd372181f830ab16f7a0e184acff2105 100644 (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);
index a43e07577901f94bc39ffe530e2b9f89f37df985..cc95c4c360f68a0d39d515d4c26a244de43ac01f 100644 (file)
@@ -25,4 +25,5 @@ public class ThingConfig {
     public String id = "";
     public int lastSeenPolling = 1440;
     public @Nullable Double transitiontime;
+    public String colormode = "";
 }
index 132f255a4b43e7c2676d39bf080e05ddc33aa756..caff776502c5c04c4ecb26137e6b96a065b9639e 100644 (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>
                </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>
index 7de5c8aca410e530f265128d409da845f36414ff..1e576e10f3d7cb47d69756c32463e662397cc868 100644 (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">
 
                <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">