Use aiohasupervisor for all calls from hassio/coordinator#164413
Use aiohasupervisor for all calls from hassio/coordinator#164413MartinHjelmare merged 15 commits intodevfrom
Conversation
|
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
|
Hey there @home-assistant/supervisor, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
There was a problem hiding this comment.
Pull request overview
This PR migrates the hassio/coordinator from using the internal HassIO HTTP handler to the aiohasupervisor Python client library for all API calls. It also removes the deprecated addons field from supervisor/info data and replaces it with a dedicated addons.list API call, storing the result as a separate hassio_addons_info hass.data key keyed by slug.
Changes:
- Replaces all
HassIO.get_*handler calls in the coordinator withaiohasupervisorclient equivalents, and moves from raw HTTP mocking to structured model fixtures in tests. - Removes the deprecated
addonsfield fromsupervisor_inforesponse and instead fetches addon list viaclient.addons.list(), storing it in a newDATA_ADDONS_INFOdict keyed by slug. - Updates consumers of addons info (analytics, websocket_api, system_health, issues) to use the new
get_addons_info()function instead ofget_supervisor_info()["addons"].
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
homeassistant/components/hassio/coordinator.py |
Core migration: replaces HassIO handler calls with aiohasupervisor client calls, changes addon data structure from list-in-supervisor-info to dict-by-slug in separate cache |
homeassistant/components/hassio/__init__.py |
Migrates update_info_data function to use aiohasupervisor client calls and convert results via .to_dict() |
homeassistant/components/hassio/handler.py |
Removes deprecated handler methods (get_info, get_host_info, etc.) now covered by aiohasupervisor |
homeassistant/components/hassio/websocket_api.py |
Updates to use get_addons_info() dict keyed by slug instead of get_supervisor_info()["addons"] list |
homeassistant/components/hassio/system_health.py |
Updates installed_addons to use new get_addons_info() dict format |
homeassistant/components/hassio/issues.py |
Fixes host_info key access: removes incorrect data nesting that was an artifact of the old HTTP response wrapper |
homeassistant/components/analytics/analytics.py |
Updates to iterate over get_addons_info() slug keys instead of supervisor_info["addons"] list |
tests/components/conftest.py |
Adds new shared fixtures for all new aiohasupervisor client mock calls; upgrades supervisor_client mock to use spec= for stronger typing |
tests/components/hassio/conftest.py |
Updates all_setup_requests fixture to use new supervisor client fixtures instead of HTTP mocks |
tests/components/hassio/test_*.py |
Multiple test files updated to use new fixtures and dataclasses.replace() for per-test mock customization |
tests/conftest.py |
Updates hassio_env and hassio_stubs to use the new supervisor_root_info fixture instead of patching HassIO.get_info |
9715239 to
f1be802
Compare
agners
left a comment
There was a problem hiding this comment.
The
hassiocomponent will no longer use it at all and instead get all of its app info from theaddons.listin the client library (this rename still has a long way to go 🙈 ). But hass data has always been public and returned from theget_supervisor_infomethod in the component. So its possible this removal could break others. You can see this in the second commit where analytics was relying on addons info coming bak fromget_supervisor_info.
In my eyes these are hassio internals which are fine to change. If custom components are relying on this data they just have to follow this change 🤷 .
From a quick grep through HACS repos get_supervisor_info is only used once, we probably can even inform that custom integration.
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
f1be802 to
6b2c719
Compare
|
Most of the get info functions are imported to the base package only so they can be imported and used by other integrations. We can see this as those imports have a lint ignore error comment. core/homeassistant/components/hassio/__init__.py Lines 102 to 111 in 6b2c719 I think all the get info functions are meant to be exposed to other integrations so we should not break them without a deprecation period, at minimum. |
|
In a follow up, I suggest we add an |
568be47 to
c9882a9
Compare
Proposed change
Replace all references to internal
HassIOhandler with aiohasupervisor inhassio/coordinator.One potentially significant result of this is the removal ofaddonsfield from supervisor info in hass data. Supervisor has marked theaddonsfield in thesupervisor/inforesponse as deprecated for quite a while so the library does not acknowledge it. However there's been a lot of use of this field despite this deprecation to this day.Update on this: the hassio component will re-add
addonsandrepositoriesinto the supervisor info in hass.data so it continues to come back fromget_supervisor_info. This will be considered deprecated though and start the timeline for removal. Integrations and other code relying on this should instead migrate to the following:get_apps_list: returns a list of apps, identical behavior to callingget_supervisor_info(hass).get("addons")today. Added with this PR.get_store(hass).get("repositories"): returns a list of repositories and some info for each. Any call toget_supervisor_info(hass).get("repositories")can be replaced with this transparently right now sinceget_storealready exists.get_storeactually returns a bit more info about each repository thenget_supervisor_infodid but the old schema is a subset of the new one, the same fields still exist.Type of change
Additional information
Checklist
ruff format 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.To help with the load of incoming pull requests: