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

Make homekit_controller a local push integration #32213

Merged
merged 1 commit into from
Feb 26, 2020

Conversation

Jc2k
Copy link
Member

@Jc2k Jc2k commented Feb 26, 2020

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

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

@codecov
Copy link

codecov bot commented Feb 26, 2020

Codecov Report

❗ No coverage uploaded for pull request base (dev@92a47f1). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##             dev   #32213   +/-   ##
======================================
  Coverage       ?   94.75%           
======================================
  Files          ?      772           
  Lines          ?    55894           
  Branches       ?        0           
======================================
  Hits           ?    52961           
  Misses         ?     2933           
  Partials       ?        0
Impacted Files Coverage Δ
...istant/components/homekit_controller/connection.py 93.08% <100%> (ø)
...stant/components/homekit_controller/config_flow.py 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 92a47f1...9802483. Read the comment docs.

@Jc2k
Copy link
Member Author

Jc2k commented Feb 26, 2020

@Jc2k Jc2k changed the title WIP: Make homekit_controller a local push integration Make homekit_controller a local push integration Feb 26, 2020
@Jc2k
Copy link
Member Author

Jc2k commented Feb 26, 2020

Cheers for merging #32212 @balloob!

Have rebased and removed the WIP tags from this PR.

@balloob balloob merged commit 853d6cd into home-assistant:dev Feb 26, 2020
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))
Copy link
Member

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.

Jc2k added a commit to Jc2k/home-assistant that referenced this pull request Feb 26, 2020
@lock lock bot locked and limited conversation to collaborators Feb 28, 2020
@Jc2k Jc2k deleted the homekit_controller_events branch March 6, 2020 17:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants