ikalchev / HAP-python

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

Best Approach to Integrate with Existing Pi Django Server #450

Closed cerahmed closed 2 months ago

cerahmed commented 11 months ago

Hi there,

Thanks for the great library!

I'm quite familiar with how the library works as a stand alone program.

However, I need some assistance in order to integrate it with my existing django server that I run on the Pi to control some relays and sensors around the home.

1) I'm thinking of having a method on the server that calls driver.start(). However start() runs a loop that blocks further code execution. Is it best to run it on a new process/thread? Or is there a better way to go about it?

2) Also, since the user (myself) of the server can choose which existing device to show on Homekit, I couldn't figure out a way to "remove" an accessory from the bridge/driver. Case: a user could potentially choose to remove a sensor from homekit (using the django front end), in which case I'm thinking I should stop the running service -> "remove" the accessory from the bridge -> re-start() the driver.

Appreciate any piece of advice you could provide.

Thanks again for the great tool.

cerahmed commented 2 months ago

Closing as I have been able to use config_changed() method of driver to refresh devices.