From 42c830bfda6a288fd8a5046715ab71758e171642 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hans-J=C3=B6rg=20Merk?= Date: Fri, 15 Oct 2021 19:37:07 +0200 Subject: [PATCH] [wemo] fix wrong brightness value for dimmer switch (#11385) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [wemo] fix wrong brightness value for dimmer switch Signed-off-by: Hans-Jörg Merk * Update bundles/org.openhab.binding.wemo/src/main/java/org/openhab/binding/wemo/internal/handler/WemoDimmerHandler.java Co-authored-by: Hilbrand Bouwkamp * Remove @Nullable on simple variable Co-authored-by: Hilbrand Bouwkamp --- .../wemo/internal/handler/WemoDimmerHandler.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/bundles/org.openhab.binding.wemo/src/main/java/org/openhab/binding/wemo/internal/handler/WemoDimmerHandler.java b/bundles/org.openhab.binding.wemo/src/main/java/org/openhab/binding/wemo/internal/handler/WemoDimmerHandler.java index 3496ae3e3fbf8..6bec2aa34ebf1 100644 --- a/bundles/org.openhab.binding.wemo/src/main/java/org/openhab/binding/wemo/internal/handler/WemoDimmerHandler.java +++ b/bundles/org.openhab.binding.wemo/src/main/java/org/openhab/binding/wemo/internal/handler/WemoDimmerHandler.java @@ -333,16 +333,17 @@ public void onValueReceived(@Nullable String variable, @Nullable String value, @ new Object[] { variable, value, service, this.getThing().getUID() }); updateStatus(ThingStatus.ONLINE); if (variable != null && value != null) { + String oldBinaryState = this.stateMap.get("BinaryState"); this.stateMap.put(variable, value); - } - if (variable != null && value != null) { switch (variable) { case "BinaryState": - State state = value.equals("0") ? OnOffType.OFF : OnOffType.ON; - logger.debug("State '{}' for device '{}' received", state, getThing().getUID()); - updateState(CHANNEL_BRIGHTNESS, state); - if (state.equals(OnOffType.OFF)) { - updateState(CHANNEL_TIMERSTART, OnOffType.OFF); + if (oldBinaryState == null || !oldBinaryState.equals(value)) { + State state = value.equals("0") ? OnOffType.OFF : OnOffType.ON; + logger.debug("State '{}' for device '{}' received", state, getThing().getUID()); + updateState(CHANNEL_BRIGHTNESS, state); + if (state.equals(OnOffType.OFF)) { + updateState(CHANNEL_TIMERSTART, OnOffType.OFF); + } } break; case "brightness":