]> git.basschouten.com Git - openhab-addons.git/commitdiff
[deconz] Fix color conversion (#16769)
authorJ-N-K <github@klug.nrw>
Fri, 17 May 2024 19:41:38 +0000 (21:41 +0200)
committerGitHub <noreply@github.com>
Fri, 17 May 2024 19:41:38 +0000 (21:41 +0200)
After core changes to ColorUtil the Y part can no longer be used as brightness.

Signed-off-by: Jan N. Klug <github@klug.nrw>
bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java

index ae7114de54d55397bfce384178b03c307ae97a5d..9c408369fcb306b677ea5764191c482e75832e52 100644 (file)
@@ -217,12 +217,12 @@ public class LightThingHandler extends DeconzBaseThingHandler {
                     } else {
                         double[] xy = ColorUtil.hsbToXY(hsbCommand);
                         newLightState.xy = new double[] { xy[0], xy[1] };
-                        newLightState.bri = (int) (xy[2] * BRIGHTNESS_MAX);
+                        newLightState.bri = Util.fromPercentType(hsbCommand.getBrightness());
                     }
-                } else if (command instanceof PercentType) {
-                    newLightState.bri = Util.fromPercentType((PercentType) command);
-                } else if (command instanceof DecimalType) {
-                    newLightState.bri = ((DecimalType) command).intValue();
+                } else if (command instanceof PercentType percentCommand) {
+                    newLightState.bri = Util.fromPercentType(percentCommand);
+                } else if (command instanceof DecimalType decimalCommand) {
+                    newLightState.bri = decimalCommand.intValue();
                 } else {
                     return;
                 }