From e7e03dac410c497a94ae857433d2ccc117d98326 Mon Sep 17 00:00:00 2001 From: Hilbrand Bouwkamp Date: Mon, 23 Dec 2019 14:03:20 +0100 Subject: [PATCH] [innogysmarthome] Don't set state twice Both dimmer and rollershutter set first the state as ONOFF and then as PercentType. It should set only one time because the percentage is the value actual wanted. Closes #6610 Signed-off-by: Hilbrand Bouwkamp --- .../internal/handler/InnogyDeviceHandler.java | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/handler/InnogyDeviceHandler.java b/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/handler/InnogyDeviceHandler.java index 856b8239d0b66..4057ad105de5c 100644 --- a/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/handler/InnogyDeviceHandler.java +++ b/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/handler/InnogyDeviceHandler.java @@ -18,6 +18,7 @@ import java.time.format.FormatStyle; import java.util.HashMap; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import org.eclipse.jdt.annotation.NonNullByDefault; @@ -389,7 +390,9 @@ public void onDeviceStateChanged(final Device device) { } // CAPABILITY STATES - for (final Capability c : device.getCapabilityMap().values()) { + for (final Entry entry : device.getCapabilityMap().entrySet()) { + final Capability c = entry.getValue(); + logger.debug("->capability:{} ({}/{})", c.getId(), c.getType(), c.getName()); if (c.getCapabilityState() == null) { @@ -420,11 +423,6 @@ public void onDeviceStateChanged(final Device device) { final Integer dimLevel = c.getCapabilityState().getDimmerActuatorState(); if (dimLevel != null) { logger.debug("Dimlevel state {}", dimLevel); - if (dimLevel > 0) { - updateState(CHANNEL_DIMMER, OnOffType.ON); - } else { - updateState(CHANNEL_DIMMER, OnOffType.OFF); - } updateState(CHANNEL_DIMMER, new PercentType(dimLevel)); } else { logger.debug("State for {} is STILL NULL!! cstate-id: {}, c-id: {}", c.getType(), @@ -436,11 +434,6 @@ public void onDeviceStateChanged(final Device device) { if (rollerShutterLevel != null) { rollerShutterLevel = invertValueIfConfigured(CHANNEL_ROLLERSHUTTER, rollerShutterLevel); logger.debug("RollerShutterlevel state {}", rollerShutterLevel); - if (rollerShutterLevel > 0) { - updateState(CHANNEL_ROLLERSHUTTER, UpDownType.DOWN); - } else { - updateState(CHANNEL_ROLLERSHUTTER, UpDownType.UP); - } updateState(CHANNEL_ROLLERSHUTTER, new PercentType(rollerShutterLevel)); } else { logger.debug("State for {} is STILL NULL!! cstate-id: {}, c-id: {}", c.getType(),