-
-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
Make homekit_controller a local push integration #32213
Conversation
69d7e56
to
5dfdb24
Compare
9c9ea6b
to
91a1766
Compare
Codecov Report
@@ Coverage Diff @@
## dev #32213 +/- ##
======================================
Coverage ? 94.75%
======================================
Files ? 772
Lines ? 55894
Branches ? 0
======================================
Hits ? 52961
Misses ? 2933
Partials ? 0
Continue to review full report at Codecov.
|
91a1766
to
9802483
Compare
def add_watchable_characteristics(self, characteristics): | ||
"""Add (aid, iid) pairs that we need to poll.""" | ||
self.watchable_characteristics.extend(characteristics) | ||
self.hass.add_job(self.pairing.subscribe(characteristics)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the target is a coroutine, we should use hass.async_create_task
instead of hass.async_add_job
. The latter is legacy for general use.
Proposed change
Now that we are using aiohomekit for homekit_controller this PR enables events. This means that accessories can now push their state changes to Home Assistant over an open HomeKit secure session as they happen. In my testing with a Phillips Hue this is near instantaneous.
We added the framework for injecting state changes from events many cycles ago (
HKDevice.process_new_events
) so this ends up being quite a modest change now we aren't restrained by a blocking client.Polling still occurs (for now) as not all characteristics support events and it seemed like a good idea to make sure we didn't "miss" any events. There are also edge cases where e.g. a device is unavailable and then becomes available - these might not trigger events. Hybrid push/poll minimizes the impact of these sorts of issues.
NOTE: This is currently behind #32212 in my patch queue. The intention is that it can be reviewed seperately to 5d31f95. I will rebase it and remove the WIP tags after that is merged.Type of change
Additional information
Checklist
black --fast homeassistant tests
)If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
.The integration reached or maintains the following Integration Quality Scale: