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

Anyone tried multiple devices/switches in Homekit example (MEGH-2692) #59

Open
adukale opened this issue Aug 4, 2021 · 3 comments
Open

Comments

@adukale
Copy link

adukale commented Aug 4, 2021

I want to integrate multiple devices/switches in Homekit example code. The homekit initialization is clear to me but I am getting confused while registering devices ans setting callbacks, so wondering if anyone has already tried this.

Thanks in advance.
Any help is appreciated.

@github-actions github-actions bot changed the title Anyone tried multiple devices/switches in Homekit example Anyone tried multiple devices/switches in Homekit example (MEGH-2692) Aug 4, 2021
@shahpiyushv shahpiyushv transferred this issue from espressif/esp-rainmaker Aug 4, 2021
@shahpiyushv
Copy link
Collaborator

@adukale , you can check the bridge example to understand how to add multiple accessories under the same node. However, if the multiple accessories (switches in your case) are co-located i.e. part of a single physical device, you just need to add multiple switch services into the same accessory. You can either have independent callbacks for each or add some private data to each switch service (some identifier or GPIO number) and have a common callback. This line shows how to add private data and that same is used here in the callback.

@adukale
Copy link
Author

adukale commented Aug 4, 2021

@shahpiyushv Thank you for quick response.
Your suggestions helped. I have modified esp_rainmaker/example/homekit_example to have 6 switches.
Here is the code sample: https://github.com/adukale/homekit_6switch

I can see 6 switches in Home app in ios/HomeKit. But turning on/off anyone of them results in rebooting esp32 and it goes into bootloop sometimes. Also, the connected gpios/relayes does not change the state.

Thanks in advance.

@adukale
Copy link
Author

adukale commented Aug 4, 2021

@shahpiyushv I resolved the error. The issue was in callback functions for homekit service. Have seperated out each callbacks for services.
Now control from ESP Rainmaker App & HomeKit app works flawlessly, the only issue is state is not persisted in homekit.
I noticed the code: app_homekit_start(DEFALT_POWER); in app_main.c. This set power to default set and does not retain the previous state.
Is there any workaround for this?
Updated code: https://github.com/adukale/homekit_6switch
Thank You

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants