-
Notifications
You must be signed in to change notification settings - Fork 110
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
How to implement automatic shutdown in switch module and update homekit state #91
Comments
@ilovn You can maintain a pointer of the characteristic and update it as shown in this example. If you do not want to maintain the pointer, you can also fetch it at runtime using a combination of |
When I use GPIO18 to control the relay to realize the circuit on and off, but updating the Homekit status still does not work properly, which UUID type with |
Since your implementation is a simple switch, you just need to call hap_acc_get_by_aid(1). This pointer is created and returned by hap_acc_create() and so you can keep a copy of that too. Standard service UUIDs can be found here and standard characteristic UUIDs can be found here. UUID for switch is HAP_SERV_UUID_SWITCH, whereas that of outlet is HAP_SERV_UUID_SWITCH. The UUID for ON characteristic is HAP_CHAR_UUID_ON. |
Through the UUID or aid you provide, the code can run normally, but the switch status in the Home App remains unchanged. |
Has iOS enabled the events? You can verify this by checking for prints like these in the serial terminal logs
If you see this, whenver you call
You may also enable additional debugging using |
mine print out |
Event subscription is managed by the iOS layer and is not in user's or accessory's control. If the serial terminal prints |
I implemented a switch module through the code example, which controls the device through the gpio control output. Now I hope to automatically turn off 30 seconds after opening. I realized the shutdown through the timer, but I can't update the state in the homekit.
The text was updated successfully, but these errors were encountered: