Skip to content

Commit

Permalink
[homekit] add Doorbell Service
Browse files Browse the repository at this point in the history
this is _not_ sufficient for HomeKit to present a doorbell.
it just shows as an unsupported accessory with the house icon,
and you can't have status or program actions on button presses

refs #9969
  • Loading branch information
ccutrer committed Jul 22, 2024
1 parent 9a19eaa commit 52ba577
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 });

Check failure on line 79 in bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitAccessoryFactory.java

View workflow job for this annotation

GitHub Actions / Build (Java 17, ubuntu-22.04)

PROGRAMMABLE_SWITCH_EVENT cannot be resolved to a variable
put(FAN, new HomekitCharacteristicType[] { ACTIVE_STATUS });
put(FAUCET, new HomekitCharacteristicType[] { ACTIVE_STATUS });
put(FILTER_MAINTENANCE, new HomekitCharacteristicType[] { FILTER_CHANGE_INDICATION });
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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<HomekitTaggedItem> mandatoryCharacteristics,
List<Characteristic> 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()));
}
}

0 comments on commit 52ba577

Please sign in to comment.