From 266bbf4c3e46a2eef20357d7a86bba971473de70 Mon Sep 17 00:00:00 2001 From: Martin Grzeslowski Date: Wed, 10 Apr 2019 20:07:39 +0200 Subject: [PATCH] #4 Support inverted logic when finding state --- .../functionswitch/FindStateFunctionSwitch.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/addons/binding/org.openhab.binding.supla/src/main/java/org/openhab/binding/supla/internal/cloud/functionswitch/FindStateFunctionSwitch.java b/addons/binding/org.openhab.binding.supla/src/main/java/org/openhab/binding/supla/internal/cloud/functionswitch/FindStateFunctionSwitch.java index e6bc78cc48f38..a45063d5bfd92 100644 --- a/addons/binding/org.openhab.binding.supla/src/main/java/org/openhab/binding/supla/internal/cloud/functionswitch/FindStateFunctionSwitch.java +++ b/addons/binding/org.openhab.binding.supla/src/main/java/org/openhab/binding/supla/internal/cloud/functionswitch/FindStateFunctionSwitch.java @@ -14,7 +14,6 @@ import java.math.BigDecimal; import java.util.Optional; -import static java.util.Optional.empty; import static java.util.Optional.of; import static org.eclipse.smarthome.core.library.types.OnOffType.OFF; import static org.eclipse.smarthome.core.library.types.OnOffType.ON; @@ -202,11 +201,11 @@ public Optional onDefault(Channel channel) { } private Optional hiType(Channel channel) { - boolean param2Present = channel.getParam2() != null && channel.getParam2() > 0; - if (param2Present || !channel.getType().isOutput()) { - return of(channel).map(Channel::getState).map(ChannelState::getHi).map(hi -> hi ? ON : OFF); - } else { - return empty(); - } + boolean invertedLogic = channel.getParam3() != null && channel.getParam3() > 1; + return of(channel) + .map(Channel::getState) + .map(ChannelState::getHi) + .map(hi -> invertedLogic ? !hi : hi) + .map(hi -> hi ? ON : OFF); } }