ikalchev / HAP-python

A python implementation of the HomeKit Accessory Protocol (HAP)
Other
630 stars 119 forks source link

Changing the State of an Accessory "Outside of HomeKit" #405

Open AlexMaghen opened 2 years ago

AlexMaghen commented 2 years ago

I'm using your GarageDoor example and I have it working but I am confused about one thing: In the very simple Python file I've included, the "GarageDoor" class's change_state() function gets called beautifully when a user taps on the accessory in iOS Home (or wherever). But what happens if the door changes state for other reasons (user opens it manually, whatever)? I don't understand how I instruct the accessory that I've created that it's status HAS CHANGED from inside my code. I think I need to use an Accessory base class function but I'm having trouble understanding this from the documentation.

Anyone's help most appreciated with this amazing library!

Ale Garagey.txt x

Pythonaire commented 2 years ago

two ways: 1) permanent polling the device (i think, not a good idea), described as "service callback" (@Acessory.run_at_interval(3)). 2) let the device inform HAP-Python about state change. See the http.py example. I use 433 MHz devices instead of Wifi, to communicate over longer distance. A device as an example send state changes, HAP-Python forward this to the homekit. https://github.com/Pythonaire/HAP-Python-RFM69