[openwebnet] Do not store dimmer brightness if already 0 (#14822)

Fixes #14785

Signed-off-by: Massimo Valla <mvcode00@gmail.com>
This commit is contained in:
M Valla 2023-04-21 13:49:07 +02:00 committed by GitHub
parent cb4d232328
commit 02fd67f6ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -194,13 +194,16 @@ public class OpenWebNetLightingHandler extends OpenWebNetThingHandler {
private void dimLightTo(int percent, Command command) { private void dimLightTo(int percent, Command command) {
logger.debug(" DIM dimLightTo({}) bri={} briBeforeOff={}", percent, brightness, brightnessBeforeOff); logger.debug(" DIM dimLightTo({}) bri={} briBeforeOff={}", percent, brightness, brightnessBeforeOff);
int newBrightness = percent; int newBrightness = percent;
if (newBrightness == UNKNOWN_STATE) { if (newBrightness == UNKNOWN_STATE) { // we do not know last brightness -> set dimmer to 100%
// we do not know last brightness -> set dimmer to 100%
newBrightness = 100; newBrightness = 100;
} else if (newBrightness <= 0) { } else if (newBrightness <= 0) {
newBrightness = 0; if (brightness == 0) {
logger.debug(" DIM bri already 0: no need to save it");
} else {
brightnessBeforeOff = brightness; brightnessBeforeOff = brightness;
logger.debug(" DIM saved bri before sending bri=0 command to device"); logger.debug(" DIM saved briBeforeOff={} before sending bri=0 command to device",
brightnessBeforeOff);
}
} else if (newBrightness > 100) { } else if (newBrightness > 100) {
newBrightness = 100; newBrightness = 100;
} }
@ -280,8 +283,7 @@ public class OpenWebNetLightingHandler extends OpenWebNetThingHandler {
return; return;
} else { } else {
// otherwise we interpret this ON event as the requestStatus response event with // otherwise we interpret this ON event as the requestStatus response event with
// level=1 // level=1 so we proceed to call updateBrightnessState()
// so we proceed to call updateBrightnessState()
logger.debug(" $BRI 'ON' is the requestStatus response level"); logger.debug(" $BRI 'ON' is the requestStatus response level");
} }
} }