Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[homekit] Add (partial) Doorbell Service #17130

Merged
merged 2 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions bundles/org.openhab.io.homekit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,10 @@ All accessories also support the following optional characteristic that can be l
| | TargetPosition | | Dimmer, Number, Rollershutter | Target position of motorized door | | |
| | | HoldPosition | Rollershutter, Switch | Motorized door should stop at its current position. ON is sent to Switch items. STOP is sent to Rollershutter items. Only supported by 3rd party Home apps (such as Elgato Eve) | | |
| | | ObstructionStatus | Contact, Dimmer, Switch | Current status of obstruction sensor. ON-obstruction detected, OFF - no obstruction | | |
| Doorbell | | | | Doorbell. This accessory must also have a Speaker, Microphone, and Camera RTP Stream Management service in the same group in order to be usable by the Home App. The latter is not yet implemented in openHAB. | | |
| | ProgrammableSwitchEvent | | Contact, Number, String, Switch | The button press event. Note that the event will be forwarded to Home for every _update_ of the item, not just on change. | inverted (false) | SINGLE_PRESS (0, ON, OPEN), DOUBLE_PRESS (1), LONG_PRESS (2) [*](#customizable-enum) |
| | | Brightness | Dimmer | Brightness in % (1-100). | | |
| | | Volume | Number | Speaker volume from 0% to 100% | | |
| Fan | | | | Fan | | |
| | ActiveStatus | | Dimmer, Switch | Accessory current working status. A value of "ON"/"OPEN" indicates that the accessory is active and is functioning without any errors. | | |
| | | CurrentFanState | Number, String | Current fan state. | | INACTIVE (0), IDLE (1), BLOWING_AIR (2) |
Expand Down
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 });
put(FAN, new HomekitCharacteristicType[] { ACTIVE_STATUS });
put(FAUCET, new HomekitCharacteristicType[] { ACTIVE_STATUS });
put(FILTER_MAINTENANCE, new HomekitCharacteristicType[] { FILTER_CHANGE_INDICATION });
Expand Down Expand Up @@ -123,6 +124,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-2024 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()));
}
}