From 02fd67f6cea1164733c73f36c7ab7a02d05895f0 Mon Sep 17 00:00:00 2001 From: M Valla <12682715+mvalla@users.noreply.github.com> Date: Fri, 21 Apr 2023 13:49:07 +0200 Subject: [PATCH] [openwebnet] Do not store dimmer brightness if already 0 (#14822) Fixes #14785 Signed-off-by: Massimo Valla --- .../handler/OpenWebNetLightingHandler.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/handler/OpenWebNetLightingHandler.java b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/handler/OpenWebNetLightingHandler.java index be43aa5230e..639b16eead6 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/handler/OpenWebNetLightingHandler.java +++ b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/handler/OpenWebNetLightingHandler.java @@ -194,13 +194,16 @@ public class OpenWebNetLightingHandler extends OpenWebNetThingHandler { private void dimLightTo(int percent, Command command) { logger.debug(" DIM dimLightTo({}) bri={} briBeforeOff={}", percent, brightness, brightnessBeforeOff); int newBrightness = percent; - if (newBrightness == UNKNOWN_STATE) { - // we do not know last brightness -> set dimmer to 100% + if (newBrightness == UNKNOWN_STATE) { // we do not know last brightness -> set dimmer to 100% newBrightness = 100; } else if (newBrightness <= 0) { - newBrightness = 0; - brightnessBeforeOff = brightness; - logger.debug(" DIM saved bri before sending bri=0 command to device"); + if (brightness == 0) { + logger.debug(" DIM bri already 0: no need to save it"); + } else { + brightnessBeforeOff = brightness; + logger.debug(" DIM saved briBeforeOff={} before sending bri=0 command to device", + brightnessBeforeOff); + } } else if (newBrightness > 100) { newBrightness = 100; } @@ -280,8 +283,7 @@ public class OpenWebNetLightingHandler extends OpenWebNetThingHandler { return; } else { // otherwise we interpret this ON event as the requestStatus response event with - // level=1 - // so we proceed to call updateBrightnessState() + // level=1 so we proceed to call updateBrightnessState() logger.debug(" $BRI 'ON' is the requestStatus response level"); } }