espressif / esp-homekit-sdk

550 stars 99 forks source link

Added doorbell service #25

Open lukehoersten opened 3 years ago

lukehoersten commented 3 years ago

The video doorbell service depends on a doorbell service which in turn depends on more services and characteristics. I've implemented that whole tree of dependencies.

The video portion of the doorbell is important because that's how the Home app connects "chimes" on the HomePods to the doorbell. The doorbell service currently works on it's own but there's no way for the Home app to configure doorbell chimes then.

The video services with the respective tlv8 configs are only stubbed out and a WIP.

NOTE: This is a work in progress. I'm looking for feedback or help with the TLV8 configs etc. I also realize I've mistakenly auto formatted the files. I'll revert this at a later point.

CLAassistant commented 3 years ago

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

lukehoersten commented 3 years ago

@Clovel Cleaned out the formatting errors I had so now you should be able to see the actual changes.

I'm looking for guidance on how to handle the TLV8 config fields:

  1. Should I have a separate TLV8 config object for each sub-service of the video doorbell that takes it's own TLV8 config?
  2. Are there TLV8 structures to provide as a part of the API to help users fill it out.

The reason I'm adding the video doorbell stuff on top of the plain doorbell service is that HAP doesn't really support standalone doorbells without video. Certain features are missing like HomePod chime configuration. So even if the doorbell doesn't have video, you need to provide a vestigial video and audio stream anyway. Any thoughts on how to approach this?

lukehoersten commented 3 years ago

Dropped the addition of both doorbell and video doorbell in favor of just the simpler doorbell first.

mcpat-it commented 2 years ago

@lukehoersten can you explain howto implement? I get the information "This accessory is not currently supported by the Homeapp." / "Dieses Gerät wird derzeit nicht von der Home-App unterstützt" on my iPhone (iOS 15.0.2).

I tried

hap_acc_cfg_t bridge_cfg_bell = {
        .name = "Esp-Doorbell",
        .manufacturer = "Espressif",
        .model = "EspDoorbell01",
        .serial_num = "abcdefg",
        .fw_rev = "0.9.0",
        .hw_rev = NULL,
        .pv = "1.1.0",
        .identify_routine = accessory_identify,
        .cid = HAP_CID_BRIDGE,
    };
    accessory = hap_acc_create(&bridge_cfg_bell);
    service_bell = hap_serv_doorbell_create(0);
    hap_serv_add_char(service_bell, hap_char_name_create("My Bell"));
    hap_serv_set_priv(service_bell, strdup("My Bell"));
    /* Set the write callback for the service - not sure if needed */
    hap_serv_set_write_cb(service_bell, fan_write);

    hap_acc_add_serv(accessory, service_bell);
    hap_add_bridged_accessory(accessory, hap_get_unique_aid("My Bell"));

But I can raise the ring event and receive a notification on iPhone and AppleTV with:

hap_char_t *temp = hap_serv_get_char_by_uuid(service_bell, HAP_CHAR_UUID_PROGRAMMABLE_SWITCH_EVENT);
    hap_val_t appliance_value = {
        .b = 1
    };
    hap_char_update_val(temp, &appliance_value);

Thx in advance

lukehoersten commented 2 years ago

Here's an example of how I use it:

https://github.com/lukehoersten/esp-homekit-intercom

Let me know if you have any questions with this concrete example.