diff --git a/bundles/org.openhab.io.homekit/README.md b/bundles/org.openhab.io.homekit/README.md index 6736931fb7c..91fe8a3e1f1 100644 --- a/bundles/org.openhab.io.homekit/README.md +++ b/bundles/org.openhab.io.homekit/README.md @@ -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. diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitTaggedItem.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitTaggedItem.java index 17a5ee64629..6a6b7826e0a 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitTaggedItem.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitTaggedItem.java @@ -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 CREATED_ACCESSORY_IDS = new ConcurrentHashMap<>(); diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/AbstractHomekitPositionAccessoryImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/AbstractHomekitPositionAccessoryImpl.java index 08ba0be13de..21fdf093499 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/AbstractHomekitPositionAccessoryImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/AbstractHomekitPositionAccessoryImpl.java @@ -56,6 +56,7 @@ abstract class AbstractHomekitPositionAccessoryImpl extends AbstractHomekitAcces private final Map 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);