espressif / esp-homekit-sdk

541 stars 98 forks source link

How to cleanly add or remove accessories ? (bridge) #121

Closed ZweiEuro closed 1 month ago

ZweiEuro commented 6 months ago

Hi! I want to try this out with a bridge. My bridge can dynamically add endpoints. I would think I can do this:

start HAP ...do other things stop HAP delete all accessories re-add all now present acessories start hap again

using delete_all_accessories and then readding doesn't work and causes a crash? Stopping and then deleting all existing accessories (bridged) and then readding them causes any home app to lose any contact, restarting fixes this.

What is the right way of doing this? It seems everytime i want to change the accessory i have to hard boot, is this really neccessary ? What would be the correct process here ?

shahpiyushv commented 2 months ago

You can remove accessories using hap_remove_bridged_accessory() and then delete them using hap_acc_delete() even without stopping HAP and then add them back as required.

ZweiEuro commented 1 month ago

I understand! thank you!