diff --git a/bundles/org.openhab.io.homekit/README.md b/bundles/org.openhab.io.homekit/README.md index 91fe8a3e1f1..88156aa0f60 100644 --- a/bundles/org.openhab.io.homekit/README.md +++ b/bundles/org.openhab.io.homekit/README.md @@ -805,6 +805,8 @@ All accessories also support the following optional characteristic that can be l | GarageDoorOpener | | | | A garage door opener. | | | | | CurrentDoorState | | Contact, Switch, Number, String | Current door state. | inverted (false) | OPEN (0, ON, OPEN), CLOSED (1, OFF, CLOSED), OPENING (2), CLOSING (3), STOPPED (4) | | | TargetDoorState | | Contact, Switch, Number, String | Target door state. | inverted (false) | OPEN (0, ON, OPEN), CLOSED (1, OFF, CLOSED) | +| | | LockCurrentState | Contact, Number, String, Switch | Current state of lock mechanism | inverted (false) | UNSECURED (0, OFF, CLOSED), SECURED (1, ON, OPEN), JAMMED (2), UNKNOWN (3) | +| | | LockTargetState | Number, String, Switch | Target state of lock mechanism | inverted (false) | UNSECURED (0, OFF), SECURED (1, ON) | | | | ObstructionStatus | Contact, Switch | Current status of obstruction sensor. ON-obstruction detected, OFF - no obstruction | inverted (false) | | | HeaterCooler | | | | Heater or/and cooler device | | | | | ActiveStatus | | Dimmer, Switch | Accessory current working status. A value of "ON"/"OPEN" indicates 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/HomekitCharacteristicFactory.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitCharacteristicFactory.java index 37fcede6c8e..5797e6238dc 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitCharacteristicFactory.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitCharacteristicFactory.java @@ -137,6 +137,10 @@ import io.github.hapjava.characteristics.impl.lightbulb.BrightnessCharacteristic import io.github.hapjava.characteristics.impl.lightbulb.ColorTemperatureCharacteristic; import io.github.hapjava.characteristics.impl.lightbulb.HueCharacteristic; import io.github.hapjava.characteristics.impl.lightbulb.SaturationCharacteristic; +import io.github.hapjava.characteristics.impl.lock.LockCurrentStateCharacteristic; +import io.github.hapjava.characteristics.impl.lock.LockCurrentStateEnum; +import io.github.hapjava.characteristics.impl.lock.LockTargetStateCharacteristic; +import io.github.hapjava.characteristics.impl.lock.LockTargetStateEnum; import io.github.hapjava.characteristics.impl.slat.CurrentTiltAngleCharacteristic; import io.github.hapjava.characteristics.impl.slat.TargetTiltAngleCharacteristic; import io.github.hapjava.characteristics.impl.television.ClosedCaptionsCharacteristic; @@ -227,6 +231,8 @@ public class HomekitCharacteristicFactory { put(INPUT_DEVICE_TYPE, HomekitCharacteristicFactory::createInputDeviceTypeCharacteristic); put(INPUT_SOURCE_TYPE, HomekitCharacteristicFactory::createInputSourceTypeCharacteristic); put(LOCK_CONTROL, HomekitCharacteristicFactory::createLockPhysicalControlsCharacteristic); + put(LOCK_CURRENT_STATE, HomekitCharacteristicFactory::createLockCurrentStateCharacteristic); + put(LOCK_TARGET_STATE, HomekitCharacteristicFactory::createLockTargetStateCharacteristic); put(MANUFACTURER, HomekitCharacteristicFactory::createManufacturerCharacteristic); put(MODEL, HomekitCharacteristicFactory::createModelCharacteristic); put(MUTE, HomekitCharacteristicFactory::createMuteCharacteristic); @@ -1097,6 +1103,23 @@ public class HomekitCharacteristicFactory { getUnsubscriber(taggedItem, LOCK_CONTROL, updater)); } + private static LockCurrentStateCharacteristic createLockCurrentStateCharacteristic(HomekitTaggedItem taggedItem, + HomekitAccessoryUpdater updater) { + var map = createMapping(taggedItem, LockCurrentStateEnum.class); + return new LockCurrentStateCharacteristic(() -> getEnumFromItem(taggedItem, map, LockCurrentStateEnum.UNKNOWN), + getSubscriber(taggedItem, LOCK_CURRENT_STATE, updater), + getUnsubscriber(taggedItem, LOCK_CURRENT_STATE, updater)); + } + + private static LockTargetStateCharacteristic createLockTargetStateCharacteristic(HomekitTaggedItem taggedItem, + HomekitAccessoryUpdater updater) { + var map = createMapping(taggedItem, LockTargetStateEnum.class); + return new LockTargetStateCharacteristic(() -> getEnumFromItem(taggedItem, map, LockTargetStateEnum.UNSECURED), + (value) -> setValueFromEnum(taggedItem, value, map), + getSubscriber(taggedItem, LOCK_TARGET_STATE, updater), + getUnsubscriber(taggedItem, LOCK_TARGET_STATE, updater)); + } + private static ManufacturerCharacteristic createManufacturerCharacteristic(HomekitTaggedItem taggedItem, HomekitAccessoryUpdater updater) { return new ManufacturerCharacteristic(() -> {