Skip to content

Use aiohasupervisor for all calls from hassio/coordinator#164413

Merged
MartinHjelmare merged 15 commits intodevfrom
refactor-hassio-to-aiohasupervisor
Mar 17, 2026
Merged

Use aiohasupervisor for all calls from hassio/coordinator#164413
MartinHjelmare merged 15 commits intodevfrom
refactor-hassio-to-aiohasupervisor

Conversation

@mdegat01
Copy link
Copy Markdown
Contributor

@mdegat01 mdegat01 commented Feb 27, 2026

Proposed change

Replace all references to internal HassIO handler with aiohasupervisor in hassio/coordinator.

One potentially significant result of this is the removal of addons field from supervisor info in hass data. Supervisor has marked the addons field in the supervisor/info response 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 addons and repositories into the supervisor info in hass.data so it continues to come back from get_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 calling get_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 to get_supervisor_info(hass).get("repositories") can be replaced with this transparently right now since get_store already exists. get_store actually returns a bit more info about each repository then get_supervisor_info did but the old schema is a subset of the new one, the same fields still exist.

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)
  • Deprecation (breaking change to happen in the future)
  • 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:
  • Link to developer documentation pull request:
  • Link to frontend pull request:

Checklist

  • I understand the code I am submitting and can explain how it works.
  • 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
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

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.
  • For the updated dependencies a diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

To help with the load of incoming pull requests:

@home-assistant
Copy link
Copy Markdown

Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration (analytics) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of analytics can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign analytics Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) on the pull request.

@home-assistant
Copy link
Copy Markdown

Hey there @home-assistant/supervisor, mind taking a look at this pull request as it has been labeled with an integration (hassio) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of hassio can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign hassio Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) on the pull request.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 with aiohasupervisor client equivalents, and moves from raw HTTP mocking to structured model fixtures in tests.
  • Removes the deprecated addons field from supervisor_info response and instead fetches addon list via client.addons.list(), storing it in a new DATA_ADDONS_INFO dict keyed by slug.
  • Updates consumers of addons info (analytics, websocket_api, system_health, issues) to use the new get_addons_info() function instead of get_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

@mdegat01 mdegat01 force-pushed the refactor-hassio-to-aiohasupervisor branch from 9715239 to f1be802 Compare February 27, 2026 23:35
Copy link
Copy Markdown
Member

@agners agners left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hassio component will no longer use it at all and instead get all of its app info from the addons.list in the client library (this rename still has a long way to go 🙈 ). But hass data has always been public and returned from the get_supervisor_info method 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 from get_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.

@home-assistant home-assistant bot marked this pull request as draft March 2, 2026 16:47
@home-assistant
Copy link
Copy Markdown

home-assistant bot commented Mar 2, 2026

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 26 out of 26 changed files in this pull request and generated 2 comments.

@MartinHjelmare
Copy link
Copy Markdown
Member

MartinHjelmare commented Mar 2, 2026

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.

get_addons_info,
get_addons_stats, # noqa: F401
get_core_info, # noqa: F401
get_core_stats, # noqa: F401
get_host_info, # noqa: F401
get_info,
get_issues_info, # noqa: F401
get_os_info,
get_supervisor_info, # noqa: F401
get_supervisor_stats, # noqa: F401

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.

@MartinHjelmare
Copy link
Copy Markdown
Member

In a follow up, I suggest we add an __all__ list to mark what names are meant for export and use by other integrations. This is the modern way for integrations to explain this.

@mdegat01 mdegat01 force-pushed the refactor-hassio-to-aiohasupervisor branch from 568be47 to c9882a9 Compare March 16, 2026 19:26
@mdegat01 mdegat01 marked this pull request as ready for review March 16, 2026 19:27
Copilot AI review requested due to automatic review settings March 16, 2026 19:27
@home-assistant home-assistant bot requested a review from agners March 16, 2026 19:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 28 out of 28 changed files in this pull request and generated 1 comment.

@MartinHjelmare MartinHjelmare merged commit 39b4444 into dev Mar 17, 2026
83 of 84 checks passed
@MartinHjelmare MartinHjelmare deleted the refactor-hassio-to-aiohasupervisor branch March 17, 2026 00:06
@github-actions github-actions bot locked and limited conversation to collaborators Mar 18, 2026
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