[homekit] Support UP/DOWN for WindowCoverings (#17138)

* [homekit] Support UP/DOWN for WindowCoverings

Signed-off-by: Cody Cutrer <cody@cutrer.us>
This commit is contained in:
Cody Cutrer 2024-07-24 12:45:19 -06:00 committed by GitHub
parent fd4dd89bb1
commit 9362fcccdc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 1 deletions

View 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.

View 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<>();

View 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);