diff --git a/bundles/org.openhab.io.homekit/README.md b/bundles/org.openhab.io.homekit/README.md index 1e41454e08601..552cd6adf0507 100644 --- a/bundles/org.openhab.io.homekit/README.md +++ b/bundles/org.openhab.io.homekit/README.md @@ -248,8 +248,8 @@ A full list of supported accessory types can be found in the table *below*. | | | CoolingThresholdTemperature | Number | maximum temperature that must be reached before cooling is turned on. min/max/step can configured at item level, e.g. minValue=10.5, maxValue=50, step=2] | | | | HeatingThresholdTemperature | Number | minimum temperature that must be reached before heating is turned on. min/max/step can configured at item level, e.g. minValue=10.5, maxValue=50, step=2] | | Lock | | | | A Lock Mechanism | -| | LockCurrentState | | Switch | current states of lock mechanism (OFF=SECURED, ON=UNSECURED) | -| | LockTargetState | | Switch | target states of lock mechanism (OFF=SECURED, ON=UNSECURED) | +| | LockCurrentState | | Switch,Number | current state of lock mechanism (1/ON=SECURED, 0/OFF=UNSECURED, 2=JAMMED, 3=UNKNOWN) | +| | LockTargetState | | Switch | target state of lock mechanism (ON=SECURED, OFF=UNSECURED) | | | | Name | String | Name of the lock | | Valve | | | | Valve. additional configuration: homekitValveType = ["Generic", "Irrigation", "Shower", "Faucet"] | | | ActiveStatus | | Switch | accessory current working status. A value of "ON"/"OPEN" indicate that the accessory is active and is functioning without any errors. | diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitLockImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitLockImpl.java index b0c8b9fbad8f5..b4645c84989d1 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitLockImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitLockImpl.java @@ -16,9 +16,12 @@ import java.util.concurrent.CompletableFuture; import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.smarthome.core.items.GenericItem; import org.eclipse.smarthome.core.items.Item; import org.eclipse.smarthome.core.library.items.SwitchItem; +import org.eclipse.smarthome.core.library.types.DecimalType; import org.eclipse.smarthome.core.library.types.OnOffType; +import org.eclipse.smarthome.core.types.State; import org.openhab.io.homekit.internal.HomekitAccessoryUpdater; import org.openhab.io.homekit.internal.HomekitCharacteristicType; import org.openhab.io.homekit.internal.HomekitSettings; @@ -47,10 +50,14 @@ public HomekitLockImpl(HomekitTaggedItem taggedItem, List man @Override public CompletableFuture getLockCurrentState() { @Nullable - OnOffType state = getStateAs(HomekitCharacteristicType.LOCK_CURRENT_STATE, OnOffType.class); - if (state != null) { + + final State state = getItem(HomekitCharacteristicType.LOCK_CURRENT_STATE, GenericItem.class).getState(); + if (state instanceof DecimalType) { + return CompletableFuture.completedFuture(LockCurrentStateEnum.fromCode( + state.as(DecimalType.class).intValue())); + } else if (state instanceof OnOffType) { return CompletableFuture.completedFuture( - state == OnOffType.OFF ? LockCurrentStateEnum.SECURED : LockCurrentStateEnum.UNSECURED); + state == OnOffType.ON ? LockCurrentStateEnum.SECURED : LockCurrentStateEnum.UNSECURED); } return CompletableFuture.completedFuture(LockCurrentStateEnum.UNKNOWN); } @@ -61,7 +68,7 @@ public CompletableFuture getLockTargetState() { OnOffType state = getStateAs(HomekitCharacteristicType.LOCK_TARGET_STATE, OnOffType.class); if (state != null) { return CompletableFuture.completedFuture( - state == OnOffType.OFF ? LockTargetStateEnum.SECURED : LockTargetStateEnum.UNSECURED); + state == OnOffType.ON ? LockTargetStateEnum.SECURED : LockTargetStateEnum.UNSECURED); } return CompletableFuture.completedFuture(LockTargetStateEnum.UNSECURED); // Apple HAP specification has onyl SECURED and UNSECURED values for lock target state. @@ -77,13 +84,13 @@ public CompletableFuture setLockTargetState(final LockTargetStateEnum stat case SECURED: // Close the door if (item instanceof SwitchItem) { - ((SwitchItem) item).send(OnOffType.OFF); + ((SwitchItem) item).send(OnOffType.ON); } break; case UNSECURED: // Open the door if (item instanceof SwitchItem) { - ((SwitchItem) item).send(OnOffType.ON); + ((SwitchItem) item).send(OnOffType.OFF); } break; default: