Robert Resch 380974eed4
Remove hassio from ALLOWED_USED_COMPONENTS and move some functions to helper (#127228)
* Remove hassio from ALLOWED_USED_COMPONENTS

* Move HassioServiceInfo to helpers.service_info

* Deprecate moved functions

* Add note about deprecation

* Fix tests

* Implement suggestion

* Typo

* Update pyproject.toml

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>

---------

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
2024-10-30 12:43:41 +01:00

30 lines
1.1 KiB
Python

"""The Hardkernel integration."""
from __future__ import annotations
from homeassistant.components.hassio import get_os_info
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers.hassio import is_hassio
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a Hardkernel config entry."""
if not is_hassio(hass):
# Not running under supervisor, Home Assistant may have been migrated
hass.async_create_task(hass.config_entries.async_remove(entry.entry_id))
return False
if (os_info := get_os_info(hass)) is None:
# The hassio integration has not yet fetched data from the supervisor
raise ConfigEntryNotReady
board: str | None
if (board := os_info.get("board")) is None or not board.startswith("odroid"):
# Not running on a Hardkernel board, Home Assistant may have been migrated
hass.async_create_task(hass.config_entries.async_remove(entry.entry_id))
return False
return True