]> git.basschouten.com Git - openhab-addons.git/commitdiff
Add virtual flag handling. (#11751)
authorMark Herwege <mherwege@users.noreply.github.com>
Sat, 11 Dec 2021 18:39:40 +0000 (19:39 +0100)
committerGitHub <noreply@github.com>
Sat, 11 Dec 2021 18:39:40 +0000 (19:39 +0100)
Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
bundles/org.openhab.binding.nikohomecontrol/src/main/java/org/openhab/binding/nikohomecontrol/internal/protocol/NikoHomeControlConstants.java
bundles/org.openhab.binding.nikohomecontrol/src/main/java/org/openhab/binding/nikohomecontrol/internal/protocol/nhc2/NhcAction2.java
bundles/org.openhab.binding.nikohomecontrol/src/main/java/org/openhab/binding/nikohomecontrol/internal/protocol/nhc2/NikoHomeControlCommunication2.java

index 55f2ca6699267b467d9d67f69a4ed5cdddc59595..f748ce3229e95bd0900da1abf5bcb9c75783b2ee 100644 (file)
@@ -35,6 +35,9 @@ public class NikoHomeControlConstants {
     public static final String NHCON = "On";
     public static final String NHCOFF = "Off";
 
+    public static final String NHCTRUE = "True";
+    public static final String NHCFALSE = "False";
+
     public static final String NHCTRIGGERED = "Triggered";
 
     // rollershutter constants in the Nhc layer
index 1155ac5b6f843253a6af44526c49f9f3acef55f6..cc65d273078157ec40af493e0db16261bc9eabfa 100644 (file)
@@ -12,6 +12,8 @@
  */
 package org.openhab.binding.nikohomecontrol.internal.protocol.nhc2;
 
+import static org.openhab.binding.nikohomecontrol.internal.protocol.NikoHomeControlConstants.*;
+
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.nikohomecontrol.internal.protocol.NhcAction;
@@ -117,7 +119,14 @@ public class NhcAction2 extends NhcAction {
     public void execute(String command) {
         logger.debug("execute action {} of type {} for {}", command, type, id);
 
-        nhcComm.executeAction(id, command);
+        String cmd;
+        if ("flag".equals(model)) {
+            cmd = NHCON.equals(command) ? NHCTRUE : NHCFALSE;
+        } else {
+            cmd = command;
+        }
+
+        nhcComm.executeAction(id, cmd);
     }
 
     /**
index 61d407f29ba0eb82d003bbcaf433494f8876420d..8cd4e82e72ce11b25ebba6ef6343542b6aa09c0a 100644 (file)
@@ -362,7 +362,7 @@ public class NikoHomeControlCommunication2 extends NikoHomeControlCommunication
                     .orElse(null);
         }
 
-        if ("action".equals(device.type)) {
+        if ("action".equals(device.type) || "virtual".equals(device.type)) {
             if (!actions.containsKey(device.uuid)) {
                 logger.debug("adding action device {}, {}", device.uuid, device.name);
 
@@ -382,6 +382,7 @@ public class NikoHomeControlCommunication2 extends NikoHomeControlCommunication
                     case "socket":
                     case "switched-generic":
                     case "switched-fan":
+                    case "flag":
                         actionType = ActionType.RELAY;
                         break;
                     case "dimmer":
@@ -480,7 +481,7 @@ public class NikoHomeControlCommunication2 extends NikoHomeControlCommunication
             booleanState = basicStateProperty.get().basicState;
         }
 
-        if (NHCOFF.equals(booleanState)) {
+        if (NHCOFF.equals(booleanState) || NHCFALSE.equals(booleanState)) {
             action.setBooleanState(false);
             logger.debug("setting action {} internally to OFF", action.getId());
         }
@@ -497,7 +498,7 @@ public class NikoHomeControlCommunication2 extends NikoHomeControlCommunication
             }
         }
 
-        if (NHCON.equals(booleanState)) {
+        if (NHCON.equals(booleanState) || NHCTRUE.equals(booleanState)) {
             action.setBooleanState(true);
             logger.debug("setting action {} internally to ON", action.getId());
         }