Skip to content

Commit

Permalink
[homekit] support Rollershutter items for HoldPosition (openhab#14045)
Browse files Browse the repository at this point in the history
* [homekit] support Rollershutter items for HoldPosition

just send STOP to them

* [homekit] log a warning for incompatible HoldPosition items

Signed-off-by: Cody Cutrer <[email protected]>
  • Loading branch information
ccutrer authored and nemerdaud committed Feb 28, 2023
1 parent 2739298 commit a4b7345
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
8 changes: 4 additions & 4 deletions bundles/org.openhab.io.homekit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -704,28 +704,28 @@ or using UI
| | TargetPosition | | Rollershutter, Dimmer, Number | Target position of motorized door |
| | PositionState | | Rollershutter, String | Position state. Supported states: DECREASING, INCREASING, STOPPED. Mapping can be redefined at item level, e.g. [DECREASING="Down", INCREASING="Up"]. If no state provided, "STOPPED" is used. |
| | | Name | String | Name of the motorized door |
| | | HoldPosition | Switch | Motorized door should stop at its current position. A value of ON must hold the state of the accessory. A value of OFF should be ignored. |
| | | HoldPosition | Switch, Rollershutter | Motorized door should stop at its current position. ON is sent to Switch items. STOP is sent to Rollershutter items. Only supported by 3rd party Home apps (such as Elgato Eve) |
| | | ObstructionStatus | Switch, Contact, Dimmer | Current status of obstruction sensor. ON-obstruction detected, OFF - no obstruction |
| Window | | | | Motorized window. One Rollershutter item covers all mandatory characteristics. see examples below. |
| | CurrentPosition | | Rollershutter, Dimmer, Number | Current position of motorized window |
| | TargetPosition | | Rollershutter, Dimmer, Number | Target position of motorized window |
| | PositionState | | Rollershutter, String | Position state. Supported states: DECREASING, INCREASING, STOPPED. Mapping can be redefined at item level, e.g. [DECREASING="Down", INCREASING="Up"]. If no state provided, "STOPPED" is used. |
| | | Name | String | Name of the motorized window |
| | | HoldPosition | Switch | Motorized door should stop at its current position. A value of ON must hold the state of the accessory. A value of OFF should be ignored. |
| | | HoldPosition | Switch, Rollershutter | Motorized door should stop at its current position. ON is sent to Switch items. STOP is sent to Rollershutter items. Only supported by 3rd party Home apps (such as Elgato Eve) |
| | | ObstructionStatus | Switch, Contact, Dimmer | Current status of obstruction sensor. ON-obstruction detected, OFF - no obstruction |
| WindowCovering | | | | Window covering / blinds. One Rollershutter item covers all mandatory characteristics. see examples below. |
| | CurrentPosition | | Rollershutter, Dimmer, Number | Current position of window covering |
| | TargetPosition | | Rollershutter, Dimmer, Number | Target position of window covering |
| | PositionState | | Rollershutter, String | Currently only "STOPPED" is supported. |
| | | Name | String | Name of the windows covering |
| | | HoldPosition | Switch | Window covering should stop at its current position. A value of ON must hold the state of the accessory. A value of OFF should be ignored. |
| | | HoldPosition | Switch, Rollershutter | Motorized door should stop at its current position. ON is sent to Switch items. STOP is sent to Rollershutter items. Only supported by 3rd party Home apps (such as Elgato Eve) |
| | | ObstructionStatus | Switch, Contact, Dimmer | Current status of obstruction sensor. ON-obstruction detected, OFF - no obstruction |
| | | CurrentHorizontalTiltAngle | Number, Dimmer | Number Item = current angle of horizontal slats. values -90 to 90. A value of 0 indicates that the slats are rotated to a fully open position. A value of -90 indicates that the slats are rotated all the way in a direction where the user-facing edge is higher than the window-facing edge. Dimmer Item = the percentage of openness (0%-100%) |
| | | TargetHorizontalTiltAngle | Number, Dimmer | Number Item = target angle of horizontal slats (-90 to +90). Dimmer Item = the percentage of openness (0%-100%) |
| | | CurrentVerticalTiltAngle | Number, Dimmer | Number Item = current angle of vertical slats (-90 to +90) . Dimmer Item = the percentage of openness (0%-100%) |
| | | TargetVerticalTiltAngle | Number, Dimmer | Number Item = target angle of vertical slats. Dimmer Item = the percentage of openness (0%-100%) |
| Slat | | | | Slat which tilts on a vertical or a horizontal axis. Configuration "type:horizontal" or "type:vertical" |
| | CurrentSlatState | | String | Current slat state. possible values (FIXED,SWINGING,JAMMED). Custom mapping can be defined at item level, e.g. [JAMMED="JAM", FIXED="FIX"] |
| | CurrentSlatState | | String | Current slat state. possible values (FIXED,SWINGING,JAMMED). Custom mapping can be defined at item level, e.g. [JAMMED="JAM", FIXED="FIX"] |
| | | Name | String | Name of the slat |
| | | SwingMode | Number, Switch | Swing mode. values: 0/OFF=SWING DISABLED, 1/ON=SWING ENABLED |
| | | CurrentTiltAngle | Number, Dimmer | Number Item = current angle of slats. values -90 to 90. A value of 0 indicates that the slats are rotated to a fully open position. Dimmer Item = the percentage of openness (0%-100%) |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.items.GenericItem;
import org.openhab.core.items.Item;
import org.openhab.core.library.items.ColorItem;
import org.openhab.core.library.items.DimmerItem;
import org.openhab.core.library.items.NumberItem;
import org.openhab.core.library.items.RollershutterItem;
import org.openhab.core.library.items.StringItem;
import org.openhab.core.library.items.SwitchItem;
import org.openhab.core.library.types.DecimalType;
Expand All @@ -40,6 +42,7 @@
import org.openhab.core.library.types.OpenClosedType;
import org.openhab.core.library.types.PercentType;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.types.StopMoveType;
import org.openhab.core.library.types.StringType;
import org.openhab.core.library.unit.ImperialUnits;
import org.openhab.core.library.unit.SIUnits;
Expand Down Expand Up @@ -471,7 +474,24 @@ private static NameCharacteristic createNameCharacteristic(HomekitTaggedItem tag

private static HoldPositionCharacteristic createHoldPositionCharacteristic(HomekitTaggedItem taggedItem,
HomekitAccessoryUpdater updater) {
return new HoldPositionCharacteristic(value -> ((SwitchItem) taggedItem.getItem()).send(OnOffType.from(value)));
final Item item = taggedItem.getBaseItem();
if (!(item instanceof SwitchItem || item instanceof RollershutterItem)) {
logger.warn(
"Item {} cannot be used for the HoldPosition characteristic; only SwitchItem and RollershutterItem are supported. Hold requests will be ignored.",
item.getName());
}

return new HoldPositionCharacteristic(value -> {
if (!value) {
return;
}

if (item instanceof SwitchItem) {
((SwitchItem) item).send(OnOffType.ON);
} else if (item instanceof RollershutterItem) {
((RollershutterItem) item).send(StopMoveType.STOP);
}
});
}

private static CarbonMonoxideLevelCharacteristic createCarbonMonoxideLevelCharacteristic(
Expand Down

0 comments on commit a4b7345

Please sign in to comment.