diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitAccessoryType.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitAccessoryType.java index f9b8c94b8052f..6f85a7e1a30bf 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitAccessoryType.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitAccessoryType.java @@ -33,6 +33,7 @@ public enum HomekitAccessoryType { CARBON_MONOXIDE_SENSOR("CarbonMonoxideSensor"), CONTACT_SENSOR("ContactSensor"), DOOR("Door"), + DOORBELL("Doorbell"), FAN("Fan"), FAUCET("Faucet"), FILTER_MAINTENANCE("Filter"), diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitAccessoryFactory.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitAccessoryFactory.java index 0e43d7dfa168b..bfcc9b5ec2e62 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitAccessoryFactory.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitAccessoryFactory.java @@ -76,6 +76,7 @@ public class HomekitAccessoryFactory { put(CARBON_MONOXIDE_SENSOR, new HomekitCharacteristicType[] { CARBON_MONOXIDE_DETECTED_STATE }); put(CONTACT_SENSOR, new HomekitCharacteristicType[] { CONTACT_SENSOR_STATE }); put(DOOR, new HomekitCharacteristicType[] { CURRENT_POSITION, TARGET_POSITION, POSITION_STATE }); + put(DOORBELL, new HomekitCharacteristicType[] { PROGRAMMABLE_SWITCH_EVENT }); put(FAN, new HomekitCharacteristicType[] { ACTIVE_STATUS }); put(FAUCET, new HomekitCharacteristicType[] { ACTIVE_STATUS }); put(FILTER_MAINTENANCE, new HomekitCharacteristicType[] { FILTER_CHANGE_INDICATION }); @@ -124,6 +125,7 @@ public class HomekitAccessoryFactory { put(CARBON_MONOXIDE_SENSOR, HomekitCarbonMonoxideSensorImpl.class); put(CONTACT_SENSOR, HomekitContactSensorImpl.class); put(DOOR, HomekitDoorImpl.class); + put(DOORBELL, HomekitDoorbellImpl.class); put(FAN, HomekitFanImpl.class); put(FAUCET, HomekitFaucetImpl.class); put(FILTER_MAINTENANCE, HomekitFilterMaintenanceImpl.class); diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitDoorbellImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitDoorbellImpl.java new file mode 100644 index 0000000000000..12a43a278a6ef --- /dev/null +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitDoorbellImpl.java @@ -0,0 +1,48 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.io.homekit.internal.accessories; + +import java.util.List; + +import org.openhab.io.homekit.internal.HomekitAccessoryUpdater; +import org.openhab.io.homekit.internal.HomekitException; +import org.openhab.io.homekit.internal.HomekitSettings; +import org.openhab.io.homekit.internal.HomekitTaggedItem; + +import io.github.hapjava.characteristics.Characteristic; +import io.github.hapjava.characteristics.impl.common.ProgrammableSwitchEventCharacteristic; +import io.github.hapjava.services.impl.DoorbellService; + +/** + * Implements a HomeKit Doorbell + * + * This is only the primary service. To implement the entire video doorbell + * profile, you also need to add a Camera RTP Stream Management service, + * a Speaker service, and Microphone service. + * + * @author Cody Cutrer - Initial contribution + */ +class HomekitDoorbellImpl extends AbstractHomekitAccessoryImpl { + + public HomekitDoorbellImpl(HomekitTaggedItem taggedItem, List mandatoryCharacteristics, + List mandatoryRawCharacteristics, HomekitAccessoryUpdater updater, + HomekitSettings settings) { + super(taggedItem, mandatoryCharacteristics, mandatoryRawCharacteristics, updater, settings); + } + + @Override + public void init() throws HomekitException { + super.init(); + addService(new DoorbellService(getCharacteristic(ProgrammableSwitchEventCharacteristic.class).get())); + } +}