espressif / esp-homekit-sdk

562 stars 104 forks source link

More than 1 accessory support without using bridge #129

Closed dzungpv closed 5 months ago

dzungpv commented 6 months ago

I want to add more than 1 accessory but seem now only have "bridge" and multi service in on accessory mention in: https://github.com/espressif/esp-homekit-sdk/issues/23#issuecomment-768265957 But I want multiple accessory for each service in it. Is there any solution? Other lib they can define multiple accessory, only difference CID and it can add to HomeKit app: https://github.com/maximkulkin/esp-homekit-demo/issues/102#issuecomment-400006900 and this: https://github.com/maximkulkin/esp-homekit-demo/issues/102#issuecomment-662327144

Other reason I do not want to use bridge solution is that some iPhone it could not add like mention in: https://github.com/espressif/esp-homekit-sdk/issues/104

shahpiyushv commented 6 months ago

The question is not clear. A single physical device can either have

shahpiyushv commented 6 months ago

The question is not clear. A single physical device can either have

dzungpv commented 6 months ago

The question is not clear. A single physical device can either have

* One accessory and multiple service under it (like light, switch, etc.)

* Multiple accessories, each with own service for light or switch.
  Both of these are as per the HomeKit Specifications which is what this SDK also supports.

My purpose is: Multiple accessories, each with own service for light or switch. but when I add multiple accessory with

    /* Add the Accessory to the HomeKit Database */
    hap_add_accessory(accessory_second);

for second accessory, a warning show "Primary Accessory already added. Use hap_add_bridged_accessory() instead" code here: https://github.com/espressif/esp-homekit-sdk/blob/43bab6f68569e26c738f0273960200c809ec0ec9/components/homekit/esp_hap_core/src/esp_hap_acc.c#L384C42-L384C116

Can you give me a sample with I want to add 3 accessory on a single physical device: thermostat, switch and a lightbulb?

AramVartanyan commented 6 months ago

Hi,

For multiple accessories implementation, you could check this example:

https://github.com/AramVartanyan/esp-homekit-sdk/blob/4e75eb0d6c024a8e10799fc4b010ebb1aca58024/examples/waterbatt/main/app_main.c#L488

Have in mind that it is not updated, but you can follow the concept.

dzungpv commented 6 months ago

Hi,

For multiple accessories implementation, you could check this example:

https://github.com/AramVartanyan/esp-homekit-sdk/blob/4e75eb0d6c024a8e10799fc4b010ebb1aca58024/examples/waterbatt/main/app_main.c#L488

Have in mind that it is not updated, but you can follow the concept.

Your sample is add multiple service to an accessory, I can achieve it already. What I want is multiple accessory on a single esp.

dzungpv commented 5 months ago

Problem solve, I just replace the bridge CID with Thermostat CID and then it same with other SDK.