[homekit] Support lock optional characteristics on GarageDoorOpener (#17141)

Signed-off-by: Cody Cutrer <cody@cutrer.us>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
Cody Cutrer 2024-07-25 08:26:32 -06:00 committed by Ciprian Pascu
parent 5b0da4e5ca
commit 2ee75a6b79
2 changed files with 25 additions and 0 deletions

View File

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

View File

@ -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(() -> {