Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[homekit] support Rollershutter items for HoldPosition #14045

Merged
merged 2 commits into from
Dec 27, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -698,28 +698,28 @@ Support for this is planned for the future release of openHAB HomeKit binding.
| | 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,17 @@ 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)));
return new HoldPositionCharacteristic(value -> {
if (!value) {
return;
}
Item item = taggedItem.getBaseItem();
if (item instanceof SwitchItem) {
((SwitchItem) item).send(OnOffType.ON);
} else if (item instanceof RollershutterItem) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

possible for item to be neither of these? Maybe we should add a final else close and log an error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call. will do (but slightly differently, so the warning comes as soon as the accessory is created, not later when a Hold is actually received).

((RollershutterItem) item).send(StopMoveType.STOP);
}
});
}

private static CarbonMonoxideLevelCharacteristic createCarbonMonoxideLevelCharacteristic(
Expand Down