]> git.basschouten.com Git - openhab-addons.git/commitdiff
[homekit] Support UP/DOWN for WindowCoverings (#17138)
authorCody Cutrer <cody@cutrer.us>
Wed, 24 Jul 2024 18:45:19 +0000 (12:45 -0600)
committerGitHub <noreply@github.com>
Wed, 24 Jul 2024 18:45:19 +0000 (20:45 +0200)
* [homekit] Support UP/DOWN for WindowCoverings

Signed-off-by: Cody Cutrer <cody@cutrer.us>
bundles/org.openhab.io.homekit/README.md
bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitTaggedItem.java
bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/AbstractHomekitPositionAccessoryImpl.java

index 6736931fb7c79c145cd45279a6ab412c2ad0c7ae..91fe8a3e1f121220c1945d6e59e0358a29386263 100644 (file)
@@ -466,6 +466,14 @@ Some blinds devices do support "STOP" command but would stop if they receive UP/
 Rollershutter window_covering "Window Rollershutter" {homekit = "WindowCovering"  [stop=true, stopSameDirection=true]}
  ```
 
+Some blinds devices do not support going to a specific position, even though they are modeled as Rollershutter items.
+The Home App only sends exact percentages by default.
+To avoid creating a rule, you can have the HomeKit addon translate 0%/100% to UP/DOWN commands.
+
+```java
+Rollershutter window_covering "Window Rollershutter" {homekit = "WindowCovering" [sendUpDownForExtents=true]}
+```
+
 Window covering can have a number of optional characteristics like horizontal & vertical tilt, obstruction status and hold position trigger.
 If your blind supports tilt, and you want to control tilt via HomeKit you need to define blind as a group.
 e.g.
index 17a5ee646298b1066a84bdfba51d856fb38521c1..6a6b7826e0aa951e6145a44fe22ae375e36aae48 100644 (file)
@@ -62,6 +62,7 @@ public class HomekitTaggedItem {
     public static final String UNIT = "unit";
     public static final String EMULATE_STOP_STATE = "stop";
     public static final String EMULATE_STOP_SAME_DIRECTION = "stopSameDirection";
+    public static final String SEND_UP_DOWN_FOR_EXTENTS = "sendUpDownForExtents";
 
     private static final Map<Integer, String> CREATED_ACCESSORY_IDS = new ConcurrentHashMap<>();
 
index 08ba0be13de798f8c00c604d132547456e7289b5..21fdf0934998255f9bb0c62cb809c43cecb4ae0f 100644 (file)
@@ -56,6 +56,7 @@ abstract class AbstractHomekitPositionAccessoryImpl extends AbstractHomekitAcces
     private final Map<PositionStateEnum, String> positionStateMapping;
     protected boolean emulateState;
     protected boolean emulateStopSameDirection;
+    protected boolean sendUpDownForExtents;
     protected PositionStateEnum emulatedState = PositionStateEnum.STOPPED;
 
     public AbstractHomekitPositionAccessoryImpl(HomekitTaggedItem taggedItem,
@@ -66,6 +67,7 @@ abstract class AbstractHomekitPositionAccessoryImpl extends AbstractHomekitAcces
         emulateState = getAccessoryConfigurationAsBoolean(HomekitTaggedItem.EMULATE_STOP_STATE, false);
         emulateStopSameDirection = getAccessoryConfigurationAsBoolean(HomekitTaggedItem.EMULATE_STOP_SAME_DIRECTION,
                 false);
+        sendUpDownForExtents = getAccessoryConfigurationAsBoolean(HomekitTaggedItem.SEND_UP_DOWN_FOR_EXTENTS, false);
         closedPosition = inverted ? 0 : 100;
         openPosition = inverted ? 100 : 0;
         positionStateMapping = createMapping(POSITION_STATE, PositionStateEnum.class);
@@ -101,7 +103,13 @@ abstract class AbstractHomekitPositionAccessoryImpl extends AbstractHomekitAcces
                     }
                     emulatedState = PositionStateEnum.STOPPED;
                 } else {
-                    itemAsRollerShutterItem.send(new PercentType(targetPosition));
+                    if (sendUpDownForExtents && targetPosition == 0) {
+                        itemAsRollerShutterItem.send(UpDownType.UP);
+                    } else if (sendUpDownForExtents && targetPosition == 100) {
+                        itemAsRollerShutterItem.send(UpDownType.DOWN);
+                    } else {
+                        itemAsRollerShutterItem.send(new PercentType(targetPosition));
+                    }
                     if (emulateState) {
                         @Nullable
                         PercentType currentPosition = item.getStateAs(PercentType.class);