-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Use the shared zeroconf instance for homekit_controller
#37691
<
8000
/h1>
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
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
Use the shared zeroconf instance for homekit_controller #37691
Conversation
Is this just because of the number of networks zeroconf discovery is happening on or is there something else going on here to make it burn cpu? |
If you have a lot of mdns traffic, each zeroconf instance is quite expensive. If you end up with two instances in the same python process they can amplify that. |
0.2.43 released with the required change in. |
@Jc2k Your approach in Jc2k/aiohomekit#7 (comment) is better. I'll rework this to use that approach unless you want to run with it. Alternatively, feel free to close this or push directly to my remote. |
If you’ve got the time to do it I’d appreciate it. I’m done for the day now but will cut a new tag first thing in the morning, then I probably won’t have any time till the evening again (on BST). |
Happy to do it. Please ping me when the new tag is cut. I'll have some time tomorrow afternoon to work on it (HST) unless your morning is early enough that I'm still up. |
@@ -3,7 +3,8 @@ | |||
"name": "HomeKit Controller", | |||
"config_flow": true, | |||
"documentation": "https://www.home-assistant.io/integrations/homekit_controller", | |||
"requirements": ["aiohomekit[IP]==0.2.41"], | |||
"requirements": ["aiohomekit[IP]==0.2.43"], |
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.
I think that you can drop [IP]
.
From our installation logs:
Requirement already satisfied: aiohomekit[IP]==0.2.41 in ./venv/lib/python3.7/site-packages (from -r requirements_all.txt (line 188)) (0.2.41)
WARNING: aiohomekit 0.2.41 does not provide the extra 'ip'
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.
👍 - it is originally supposed to have an [IP] feature flag, but it is getting all the deps Home Assistant needs without it and until add aio ble support to it we don't need the flag.
Thanks. Will make adjustments later today. |
44c063b
to
90e41d1
Compare
I can't get homekit controller to discover my iDevices Switch. |
I think I broke something in zeroconf. Edit: fixed here #37725 Also I think there is a timeout in Digging in with testing |
EDIT: Fixed here Jc2k/aiohomekit#8 |
Will need to bump the version one more time and then it should be good to go |
Oh, the package isn't published yet. |
Flaky test whilst I was cooking tea! It should auto publish in a few minutes. |
It's there! https://pypi.org/project/aiohomekit/ |
All looks good. @Jc2k |
Yep the plan was to do something like that to keep the port and ip up to date in the config entry. Then the call to discover the ip and port in HomeKitConnection probably wouldn’t be needed. Or at least maybe it could only be invoked on retries. Would happily take a PR for it, otherwise it’s on my todo list. I want to try and polish of my programmable stateless switch branch before I start anything else though. On the topic of zeroconf, I’d also like to expire discoveries that go offline as well. I don’t know if the zeroconf module has anything that could help with that? Also if we could get the raw data when a zeroconf record is processed then we could pass the raw struct to aiohomekit instead of the device id. That would save us having to do a aiohomekit discovery at all in the step_zeroconf case. |
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.
LGTM
Thanks for validating I was reading things correctly. Right now rediscovering is a feature since there could be significant time from when the device is discovered and when the button is clicked. zeroconf does generate listener events when an mdns entry is removed/expired so it should be possible to capture those in the future. Added your notes to my list of things to look into (its a long list now though!). |
Proposed change
Should fix the cpu issue reported here
https://community.home-assistant.io/t/python3-high-cpu-usage/160012/26?u=bdraco
aiohomekit 0.2.45 supports using the shared zeroconf instance and significantly reduces the time needed to initialize configuration of new homekit controller devices.
Requires Jc2k/aiohomekit#6
Requires Jc2k/aiohomekit#7
Requires Jc2k/aiohomekit#8
Type of change
Example entry for
configuration.yaml
:# Example configuration.yaml
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
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
..coveragerc
.The integration reached or maintains the following Integration Quality Scale: