2019-02-14 15:01:46 +00:00
|
|
|
"""Support for Hass.io."""
|
2021-03-18 08:25:40 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
2021-10-22 10:23:21 +00:00
|
|
|
import asyncio
|
2023-10-06 10:14:48 +00:00
|
|
|
from collections import defaultdict
|
2023-01-27 02:06:22 +00:00
|
|
|
from contextlib import suppress
|
2023-04-20 18:56:45 +00:00
|
|
|
from datetime import datetime, timedelta
|
2017-04-07 05:19:08 +00:00
|
|
|
import logging
|
|
|
|
import os
|
2023-09-12 13:59:12 +00:00
|
|
|
import re
|
2021-09-03 22:44:01 +00:00
|
|
|
from typing import Any, NamedTuple
|
2017-04-07 05:19:08 +00:00
|
|
|
|
2017-10-04 05:52:45 +00:00
|
|
|
import voluptuous as vol
|
2017-04-07 05:19:08 +00:00
|
|
|
|
2018-11-25 17:04:48 +00:00
|
|
|
from homeassistant.auth.const import GROUP_ID_ADMIN
|
2023-10-23 18:26:56 +00:00
|
|
|
from homeassistant.components import panel_custom
|
|
|
|
from homeassistant.components.homeassistant import async_set_stop_handler
|
2021-03-01 08:41:04 +00:00
|
|
|
from homeassistant.config_entries import ConfigEntry
|
2018-01-21 06:35:38 +00:00
|
|
|
from homeassistant.const import (
|
2021-10-25 11:15:00 +00:00
|
|
|
ATTR_MANUFACTURER,
|
2021-02-23 08:56:44 +00:00
|
|
|
ATTR_NAME,
|
2019-12-08 15:33:22 +00:00
|
|
|
EVENT_CORE_CONFIG_UPDATE,
|
2021-12-09 00:49:35 +00:00
|
|
|
HASSIO_USER_NAME,
|
2021-12-06 03:10:07 +00:00
|
|
|
Platform,
|
2019-07-31 19:25:30 +00:00
|
|
|
)
|
2021-12-28 13:19:14 +00:00
|
|
|
from homeassistant.core import (
|
2023-10-06 10:14:48 +00:00
|
|
|
CALLBACK_TYPE,
|
2024-01-08 09:08:09 +00:00
|
|
|
Event,
|
2023-04-20 18:56:45 +00:00
|
|
|
HassJob,
|
2021-12-28 13:19:14 +00:00
|
|
|
HomeAssistant,
|
|
|
|
ServiceCall,
|
2023-08-29 17:57:41 +00:00
|
|
|
async_get_hass,
|
2021-12-28 13:19:14 +00:00
|
|
|
callback,
|
|
|
|
)
|
2019-02-14 15:01:46 +00:00
|
|
|
from homeassistant.exceptions import HomeAssistantError
|
2023-10-23 18:26:56 +00:00
|
|
|
from homeassistant.helpers import config_validation as cv, device_registry as dr
|
2022-05-18 15:58:28 +00:00
|
|
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
2023-10-25 13:32:43 +00:00
|
|
|
from homeassistant.helpers.debounce import Debouncer
|
2023-08-11 02:04:26 +00:00
|
|
|
from homeassistant.helpers.device_registry import DeviceInfo
|
2023-08-28 15:21:05 +00:00
|
|
|
from homeassistant.helpers.event import async_call_later
|
2022-05-17 16:45:57 +00:00
|
|
|
from homeassistant.helpers.storage import Store
|
2021-05-24 17:23:16 +00:00
|
|
|
from homeassistant.helpers.typing import ConfigType
|
2022-04-04 15:34:06 +00:00
|
|
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
2024-02-28 02:30:48 +00:00
|
|
|
from homeassistant.util.async_ import create_eager_task
|
2023-09-27 11:32:30 +00:00
|
|
|
from homeassistant.util.dt import now
|
2018-05-14 11:05:52 +00:00
|
|
|
|
2022-11-10 09:09:52 +00:00
|
|
|
from .addon_manager import AddonError, AddonInfo, AddonManager, AddonState # noqa: F401
|
2019-04-19 07:43:47 +00:00
|
|
|
from .addon_panel import async_setup_addon_panel
|
2019-12-08 15:33:22 +00:00
|
|
|
from .auth import async_setup_auth_view
|
2021-02-15 17:18:45 +00:00
|
|
|
from .const import (
|
|
|
|
ATTR_ADDON,
|
|
|
|
ATTR_ADDONS,
|
2022-04-01 15:31:39 +00:00
|
|
|
ATTR_AUTO_UPDATE,
|
2022-03-22 11:21:12 +00:00
|
|
|
ATTR_CHANGELOG,
|
2022-04-27 09:41:16 +00:00
|
|
|
ATTR_COMPRESSED,
|
2021-02-15 17:18:45 +00:00
|
|
|
ATTR_FOLDERS,
|
|
|
|
ATTR_HOMEASSISTANT,
|
2023-10-22 21:40:44 +00:00
|
|
|
ATTR_HOMEASSISTANT_EXCLUDE_DATABASE,
|
2021-02-15 17:18:45 +00:00
|
|
|
ATTR_INPUT,
|
2023-05-24 08:33:41 +00:00
|
|
|
ATTR_LOCATION,
|
2021-02-15 17:18:45 +00:00
|
|
|
ATTR_PASSWORD,
|
2021-03-01 08:41:04 +00:00
|
|
|
ATTR_REPOSITORY,
|
|
|
|
ATTR_SLUG,
|
2021-10-26 17:58:17 +00:00
|
|
|
ATTR_STARTED,
|
|
|
|
ATTR_STATE,
|
2021-03-01 08:41:04 +00:00
|
|
|
ATTR_URL,
|
|
|
|
ATTR_VERSION,
|
2023-10-22 16:40:48 +00:00
|
|
|
CONTAINER_CHANGELOG,
|
|
|
|
CONTAINER_INFO,
|
|
|
|
CONTAINER_STATS,
|
|
|
|
CORE_CONTAINER,
|
2021-10-22 10:23:21 +00:00
|
|
|
DATA_KEY_ADDONS,
|
2022-03-22 11:21:12 +00:00
|
|
|
DATA_KEY_CORE,
|
2023-03-13 14:39:49 +00:00
|
|
|
DATA_KEY_HOST,
|
2022-03-22 11:21:12 +00:00
|
|
|
DATA_KEY_OS,
|
|
|
|
DATA_KEY_SUPERVISOR,
|
2023-04-19 06:07:38 +00:00
|
|
|
DATA_KEY_SUPERVISOR_ISSUES,
|
2021-02-15 17:18:45 +00:00
|
|
|
DOMAIN,
|
2023-10-25 13:32:43 +00:00
|
|
|
REQUEST_REFRESH_DELAY,
|
2023-10-22 16:40:48 +00:00
|
|
|
SUPERVISOR_CONTAINER,
|
2021-06-28 11:49:58 +00:00
|
|
|
SupervisorEntityModel,
|
2021-02-15 17:18:45 +00:00
|
|
|
)
|
2021-12-03 13:05:56 +00:00
|
|
|
from .discovery import HassioServiceInfo, async_setup_discovery_view # noqa: F401
|
2022-11-10 09:09:52 +00:00
|
|
|
from .handler import ( # noqa: F401
|
|
|
|
HassIO,
|
|
|
|
HassioAPIError,
|
|
|
|
async_create_backup,
|
|
|
|
async_get_addon_discovery_info,
|
|
|
|
async_get_addon_info,
|
|
|
|
async_get_addon_store_info,
|
2023-09-28 15:45:10 +00:00
|
|
|
async_get_green_settings,
|
2023-04-26 15:02:52 +00:00
|
|
|
async_get_yellow_settings,
|
2022-11-10 09:09:52 +00:00
|
|
|
async_install_addon,
|
2023-04-26 15:02:52 +00:00
|
|
|
async_reboot_host,
|
2022-11-10 09:09:52 +00:00
|
|
|
async_restart_addon,
|
|
|
|
async_set_addon_options,
|
2023-09-28 15:45:10 +00:00
|
|
|
async_set_green_settings,
|
2023-04-26 15:02:52 +00:00
|
|
|
async_set_yellow_settings,
|
2022-11-10 09:09:52 +00:00
|
|
|
async_start_addon,
|
|
|
|
async_stop_addon,
|
|
|
|
async_uninstall_addon,
|
|
|
|
async_update_addon,
|
|
|
|
async_update_core,
|
|
|
|
async_update_diagnostics,
|
|
|
|
async_update_os,
|
|
|
|
async_update_supervisor,
|
|
|
|
)
|
2018-02-20 23:24:31 +00:00
|
|
|
from .http import HassIOView
|
2019-04-19 07:43:47 +00:00
|
|
|
from .ingress import async_setup_ingress_view
|
2023-03-13 08:44:20 +00:00
|
|
|
from .issues import SupervisorIssues
|
2021-02-15 17:18:45 +00:00
|
|
|
from .websocket_api import async_load_websocket_api
|
2017-04-07 05:19:08 +00:00
|
|
|
|
2017-04-30 05:04:49 +00:00
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
2021-02-15 17:18:45 +00:00
|
|
|
|
2018-07-23 12:14:57 +00:00
|
|
|
STORAGE_KEY = DOMAIN
|
|
|
|
STORAGE_VERSION = 1
|
2022-03-22 11:21:12 +00:00
|
|
|
PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR, Platform.UPDATE]
|
2017-04-07 05:19:08 +00:00
|
|
|
|
2019-07-31 19:25:30 +00:00
|
|
|
CONF_FRONTEND_REPO = "development_repo"
|
2018-05-29 06:51:08 +00:00
|
|
|
|
2019-07-31 19:25:30 +00:00
|
|
|
CONFIG_SCHEMA = vol.Schema(
|
|
|
|
{vol.Optional(DOMAIN): vol.Schema({vol.Optional(CONF_FRONTEND_REPO): cv.isdir})},
|
|
|
|
extra=vol.ALLOW_EXTRA,
|
|
|
|
)
|
2018-05-29 06:51:08 +00:00
|
|
|
|
|
|
|
|
2020-08-12 06:00:38 +00:00
|
|
|
DATA_CORE_INFO = "hassio_core_info"
|
2023-03-09 18:06:35 +00:00
|
|
|
DATA_CORE_STATS = "hassio_core_stats"
|
2020-11-11 19:12:24 +00:00
|
|
|
DATA_HOST_INFO = "hassio_host_info"
|
2021-05-31 12:06:11 +00:00
|
|
|
DATA_STORE = "hassio_store"
|
2020-11-11 19:12:24 +00:00
|
|
|
DATA_INFO = "hassio_info"
|
|
|
|
DATA_OS_INFO = "hassio_os_info"
|
|
|
|
DATA_SUPERVISOR_INFO = "hassio_supervisor_info"
|
2023-03-09 18:06:35 +00:00
|
|
|
DATA_SUPERVISOR_STATS = "hassio_supervisor_stats"
|
2022-03-22 11:21:12 +00:00
|
|
|
DATA_ADDONS_CHANGELOGS = "hassio_addons_changelogs"
|
2022-04-01 15:31:39 +00:00
|
|
|
DATA_ADDONS_INFO = "hassio_addons_info"
|
2021-10-22 10:23:21 +00:00
|
|
|
DATA_ADDONS_STATS = "hassio_addons_stats"
|
|
|
|
HASSIO_UPDATE_INTERVAL = timedelta(minutes=5)
|
2018-01-10 18:48:31 +00:00
|
|
|
|
2021-03-01 08:41:04 +00:00
|
|
|
ADDONS_COORDINATOR = "hassio_addons_coordinator"
|
|
|
|
|
2019-07-31 19:25:30 +00:00
|
|
|
SERVICE_ADDON_START = "addon_start"
|
|
|
|
SERVICE_ADDON_STOP = "addon_stop"
|
|
|
|
SERVICE_ADDON_RESTART = "addon_restart"
|
2021-03-01 08:41:04 +00:00
|
|
|
SERVICE_ADDON_UPDATE = "addon_update"
|
2019-07-31 19:25:30 +00:00
|
|
|
SERVICE_ADDON_STDIN = "addon_stdin"
|
|
|
|
SERVICE_HOST_SHUTDOWN = "host_shutdown"
|
|
|
|
SERVICE_HOST_REBOOT = "host_reboot"
|
2021-08-02 09:07:21 +00:00
|
|
|
SERVICE_BACKUP_FULL = "backup_full"
|
|
|
|
SERVICE_BACKUP_PARTIAL = "backup_partial"
|
2019-07-31 19:25:30 +00:00
|
|
|
SERVICE_RESTORE_FULL = "restore_full"
|
|
|
|
SERVICE_RESTORE_PARTIAL = "restore_partial"
|
|
|
|
|
2023-09-12 13:59:12 +00:00
|
|
|
VALID_ADDON_SLUG = vol.Match(re.compile(r"^[-_.A-Za-z0-9]+$"))
|
|
|
|
|
2017-10-04 05:52:45 +00:00
|
|
|
|
2023-08-29 17:57:41 +00:00
|
|
|
def valid_addon(value: Any) -> str:
|
|
|
|
"""Validate value is a valid addon slug."""
|
2023-09-12 13:59:12 +00:00
|
|
|
value = VALID_ADDON_SLUG(value)
|
2023-08-29 17:57:41 +00:00
|
|
|
|
|
|
|
hass: HomeAssistant | None = None
|
|
|
|
with suppress(HomeAssistantError):
|
|
|
|
hass = async_get_hass()
|
|
|
|
|
|
|
|
if hass and (addons := get_addons_info(hass)) is not None and value not in addons:
|
|
|
|
raise vol.Invalid("Not a valid add-on slug")
|
|
|
|
return value
|
|
|
|
|
|
|
|
|
2018-01-10 18:48:31 +00:00
|
|
|
SCHEMA_NO_DATA = vol.Schema({})
|
|
|
|
|
2023-08-29 17:57:41 +00:00
|
|
|
SCHEMA_ADDON = vol.Schema({vol.Required(ATTR_ADDON): valid_addon})
|
2017-10-04 05:52:45 +00:00
|
|
|
|
2019-07-31 19:25:30 +00:00
|
|
|
SCHEMA_ADDON_STDIN = SCHEMA_ADDON.extend(
|
|
|
|
{vol.Required(ATTR_INPUT): vol.Any(dict, cv.string)}
|
|
|
|
)
|
2017-10-04 05:52:45 +00:00
|
|
|
|
2021-08-02 09:07:21 +00:00
|
|
|
SCHEMA_BACKUP_FULL = vol.Schema(
|
2022-04-27 09:41:16 +00:00
|
|
|
{
|
2023-06-13 09:41:53 +00:00
|
|
|
vol.Optional(
|
2023-09-27 11:32:30 +00:00
|
|
|
ATTR_NAME, default=lambda: now().strftime("%Y-%m-%d %H:%M:%S")
|
2023-06-13 09:41:53 +00:00
|
|
|
): cv.string,
|
2022-04-27 09:41:16 +00:00
|
|
|
vol.Optional(ATTR_PASSWORD): cv.string,
|
|
|
|
vol.Optional(ATTR_COMPRESSED): cv.boolean,
|
2023-05-24 08:33:41 +00:00
|
|
|
vol.Optional(ATTR_LOCATION): vol.All(
|
|
|
|
cv.string, lambda v: None if v == "/backup" else v
|
|
|
|
),
|
2023-10-22 21:40:44 +00:00
|
|
|
vol.Optional(ATTR_HOMEASSISTANT_EXCLUDE_DATABASE): cv.boolean,
|
2022-04-27 09:41:16 +00:00
|
|
|
}
|
2019-07-31 19:25:30 +00:00
|
|
|
)
|
2018-01-10 18:48:31 +00:00
|
|
|
|
2021-08-02 09:07:21 +00:00
|
|
|
SCHEMA_BACKUP_PARTIAL = SCHEMA_BACKUP_FULL.extend(
|
2019-07-31 19:25:30 +00:00
|
|
|
{
|
2022-02-23 16:38:52 +00:00
|
|
|
vol.Optional(ATTR_HOMEASSISTANT): cv.boolean,
|
2019-07-31 19:25:30 +00:00
|
|
|
vol.Optional(ATTR_FOLDERS): vol.All(cv.ensure_list, [cv.string]),
|
2023-08-29 17:57:41 +00:00
|
|
|
vol.Optional(ATTR_ADDONS): vol.All(cv.ensure_list, [cv.slug]),
|
2019-07-31 19:25:30 +00:00
|
|
|
}
|
|
|
|
)
|
2018-01-10 18:48:31 +00:00
|
|
|
|
2019-07-31 19:25:30 +00:00
|
|
|
SCHEMA_RESTORE_FULL = vol.Schema(
|
2021-08-02 09:07:21 +00:00
|
|
|
{
|
2021-10-14 08:00:44 +00:00
|
|
|
vol.Required(ATTR_SLUG): cv.slug,
|
2021-08-02 09:07:21 +00:00
|
|
|
vol.Optional(ATTR_PASSWORD): cv.string,
|
2021-10-14 08:00:44 +00:00
|
|
|
}
|
2019-07-31 19:25:30 +00:00
|
|
|
)
|
2018-01-10 18:48:31 +00:00
|
|
|
|
2019-07-31 19:25:30 +00:00
|
|
|
SCHEMA_RESTORE_PARTIAL = SCHEMA_RESTORE_FULL.extend(
|
|
|
|
{
|
|
|
|
vol.Optional(ATTR_HOMEASSISTANT): cv.boolean,
|
|
|
|
vol.Optional(ATTR_FOLDERS): vol.All(cv.ensure_list, [cv.string]),
|
2023-08-29 17:57:41 +00:00
|
|
|
vol.Optional(ATTR_ADDONS): vol.All(cv.ensure_list, [cv.slug]),
|
2019-07-31 19:25:30 +00:00
|
|
|
}
|
|
|
|
)
|
2018-01-10 18:48:31 +00:00
|
|
|
|
2021-02-15 17:18:45 +00:00
|
|
|
|
2021-09-03 22:44:01 +00:00
|
|
|
class APIEndpointSettings(NamedTuple):
|
|
|
|
"""Settings for API endpoint."""
|
|
|
|
|
|
|
|
command: str
|
|
|
|
schema: vol.Schema
|
2021-09-29 07:46:05 +00:00
|
|
|
timeout: int | None = 60
|
2021-09-03 22:44:01 +00:00
|
|
|
pass_data: bool = False
|
|
|
|
|
|
|
|
|
2017-10-04 05:52:45 +00:00
|
|
|
MAP_SERVICE_API = {
|
2021-09-03 22:44:01 +00:00
|
|
|
SERVICE_ADDON_START: APIEndpointSettings("/addons/{addon}/start", SCHEMA_ADDON),
|
|
|
|
SERVICE_ADDON_STOP: APIEndpointSettings("/addons/{addon}/stop", SCHEMA_ADDON),
|
|
|
|
SERVICE_ADDON_RESTART: APIEndpointSettings("/addons/{addon}/restart", SCHEMA_ADDON),
|
|
|
|
SERVICE_ADDON_UPDATE: APIEndpointSettings("/addons/{addon}/update", SCHEMA_ADDON),
|
|
|
|
SERVICE_ADDON_STDIN: APIEndpointSettings(
|
|
|
|
"/addons/{addon}/stdin", SCHEMA_ADDON_STDIN
|
|
|
|
),
|
|
|
|
SERVICE_HOST_SHUTDOWN: APIEndpointSettings("/host/shutdown", SCHEMA_NO_DATA),
|
|
|
|
SERVICE_HOST_REBOOT: APIEndpointSettings("/host/reboot", SCHEMA_NO_DATA),
|
|
|
|
SERVICE_BACKUP_FULL: APIEndpointSettings(
|
|
|
|
"/backups/new/full",
|
|
|
|
SCHEMA_BACKUP_FULL,
|
2021-09-29 07:46:05 +00:00
|
|
|
None,
|
2021-09-03 22:44:01 +00:00
|
|
|
True,
|
|
|
|
),
|
|
|
|
SERVICE_BACKUP_PARTIAL: APIEndpointSettings(
|
2021-08-02 09:07:21 +00:00
|
|
|
"/backups/new/partial",
|
|
|
|
SCHEMA_BACKUP_PARTIAL,
|
2021-09-29 07:46:05 +00:00
|
|
|
None,
|
2019-07-31 19:25:30 +00:00
|
|
|
True,
|
|
|
|
),
|
2021-09-03 22:44:01 +00:00
|
|
|
SERVICE_RESTORE_FULL: APIEndpointSettings(
|
2021-08-02 09:07:21 +00:00
|
|
|
"/backups/{slug}/restore/full",
|
2019-07-31 19:25:30 +00:00
|
|
|
SCHEMA_RESTORE_FULL,
|
2021-09-29 07:46:05 +00:00
|
|
|
None,
|
2019-07-31 19:25:30 +00:00
|
|
|
True,
|
|
|
|
),
|
2021-09-03 22:44:01 +00:00
|
|
|
SERVICE_RESTORE_PARTIAL: APIEndpointSettings(
|
2021-08-02 09:07:21 +00:00
|
|
|
"/backups/{slug}/restore/partial",
|
2019-07-31 19:25:30 +00:00
|
|
|
SCHEMA_RESTORE_PARTIAL,
|
2021-09-29 07:46:05 +00:00
|
|
|
None,
|
2019-07-31 19:25:30 +00:00
|
|
|
True,
|
|
|
|
),
|
2017-10-04 05:52:45 +00:00
|
|
|
}
|
|
|
|
|
2022-05-25 18:39:15 +00:00
|
|
|
HARDWARE_INTEGRATIONS = {
|
2023-08-30 14:37:13 +00:00
|
|
|
"green": "homeassistant_green",
|
2022-06-09 14:09:00 +00:00
|
|
|
"odroid-c2": "hardkernel",
|
|
|
|
"odroid-c4": "hardkernel",
|
2023-03-09 13:18:19 +00:00
|
|
|
"odroid-m1": "hardkernel",
|
2024-02-27 20:51:55 +00:00
|
|
|
"odroid-m1s": "hardkernel",
|
2022-06-09 14:09:00 +00:00
|
|
|
"odroid-n2": "hardkernel",
|
|
|
|
"odroid-xu4": "hardkernel",
|
|
|
|
"rpi2": "raspberry_pi",
|
|
|
|
"rpi3": "raspberry_pi",
|
|
|
|
"rpi3-64": "raspberry_pi",
|
|
|
|
"rpi4": "raspberry_pi",
|
|
|
|
"rpi4-64": "raspberry_pi",
|
2023-12-18 18:31:37 +00:00
|
|
|
"rpi5-64": "raspberry_pi",
|
2022-06-14 06:25:11 +00:00
|
|
|
"yellow": "homeassistant_yellow",
|
2022-05-25 18:39:15 +00:00
|
|
|
}
|
|
|
|
|
2017-04-07 05:19:08 +00:00
|
|
|
|
2023-03-23 08:18:35 +00:00
|
|
|
def hostname_from_addon_slug(addon_slug: str) -> str:
|
|
|
|
"""Return hostname of add-on."""
|
|
|
|
return addon_slug.replace("_", "-")
|
|
|
|
|
|
|
|
|
2018-01-12 14:29:58 +00:00
|
|
|
@callback
|
2022-12-02 10:18:49 +00:00
|
|
|
def get_info(hass: HomeAssistant) -> dict[str, Any] | None:
|
2020-08-12 06:00:38 +00:00
|
|
|
"""Return generic information from Supervisor.
|
2018-01-12 14:29:58 +00:00
|
|
|
|
|
|
|
Async friendly.
|
|
|
|
"""
|
2020-08-12 06:00:38 +00:00
|
|
|
return hass.data.get(DATA_INFO)
|
2020-05-12 22:27:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
@callback
|
2022-12-02 10:18:49 +00:00
|
|
|
def get_host_info(hass: HomeAssistant) -> dict[str, Any] | None:
|
2020-08-12 06:00:38 +00:00
|
|
|
"""Return generic host information.
|
2020-05-12 22:27:34 +00:00
|
|
|
|
|
|
|
Async friendly.
|
|
|
|
"""
|
2020-08-12 06:00:38 +00:00
|
|
|
return hass.data.get(DATA_HOST_INFO)
|
2020-05-12 22:27:34 +00:00
|
|
|
|
|
|
|
|
2021-05-31 12:06:11 +00:00
|
|
|
@callback
|
2022-12-02 10:18:49 +00:00
|
|
|
def get_store(hass: HomeAssistant) -> dict[str, Any] | None:
|
2021-05-31 12:06:11 +00:00
|
|
|
"""Return store information.
|
|
|
|
|
|
|
|
Async friendly.
|
|
|
|
"""
|
|
|
|
return hass.data.get(DATA_STORE)
|
|
|
|
|
|
|
|
|
2020-11-11 19:12:24 +00:00
|
|
|
@callback
|
2022-11-29 18:22:36 +00:00
|
|
|
def get_supervisor_info(hass: HomeAssistant) -> dict[str, Any] | None:
|
2020-11-11 19:12:24 +00:00
|
|
|
"""Return Supervisor information.
|
|
|
|
|
|
|
|
Async friendly.
|
|
|
|
"""
|
|
|
|
return hass.data.get(DATA_SUPERVISOR_INFO)
|
|
|
|
|
|
|
|
|
2022-04-01 15:31:39 +00:00
|
|
|
@callback
|
2023-05-30 20:08:45 +00:00
|
|
|
def get_addons_info(hass: HomeAssistant) -> dict[str, dict[str, Any]] | None:
|
2022-04-01 15:31:39 +00:00
|
|
|
"""Return Addons info.
|
|
|
|
|
|
|
|
Async friendly.
|
|
|
|
"""
|
|
|
|
return hass.data.get(DATA_ADDONS_INFO)
|
|
|
|
|
|
|
|
|
2021-10-22 10:23:21 +00:00
|
|
|
@callback
|
2024-01-08 09:08:09 +00:00
|
|
|
def get_addons_stats(hass: HomeAssistant) -> dict[str, Any]:
|
2021-10-22 10:23:21 +00:00
|
|
|
"""Return Addons stats.
|
|
|
|
|
|
|
|
Async friendly.
|
|
|
|
"""
|
2023-10-25 13:32:43 +00:00
|
|
|
return hass.data.get(DATA_ADDONS_STATS) or {}
|
2021-10-22 10:23:21 +00:00
|
|
|
|
|
|
|
|
2023-03-09 18:06:35 +00:00
|
|
|
@callback
|
2024-01-08 09:08:09 +00:00
|
|
|
def get_core_stats(hass: HomeAssistant) -> dict[str, Any]:
|
2023-03-09 18:06:35 +00:00
|
|
|
"""Return core stats.
|
|
|
|
|
|
|
|
Async friendly.
|
|
|
|
"""
|
2023-10-25 13:32:43 +00:00
|
|
|
return hass.data.get(DATA_CORE_STATS) or {}
|
2023-03-09 18:06:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
@callback
|
2024-01-08 09:08:09 +00:00
|
|
|
def get_supervisor_stats(hass: HomeAssistant) -> dict[str, Any]:
|
2023-03-09 18:06:35 +00:00
|
|
|
"""Return supervisor stats.
|
|
|
|
|
|
|
|
Async friendly.
|
|
|
|
"""
|
2023-10-25 13:32:43 +00:00
|
|
|
return hass.data.get(DATA_SUPERVISOR_STATS) or {}
|
2023-03-09 18:06:35 +00:00
|
|
|
|
|
|
|
|
2022-03-22 11:21:12 +00:00
|
|
|
@callback
|
2024-01-08 09:08:09 +00:00
|
|
|
def get_addons_changelogs(hass: HomeAssistant):
|
2022-03-22 11:21:12 +00:00
|
|
|
"""Return Addons changelogs.
|
|
|
|
|
|
|
|
Async friendly.
|
|
|
|
"""
|
|
|
|
return hass.data.get(DATA_ADDONS_CHANGELOGS)
|
|
|
|
|
|
|
|
|
2020-11-11 19:12:24 +00:00
|
|
|
@callback
|
2022-12-02 10:18:49 +00:00
|
|
|
def get_os_info(hass: HomeAssistant) -> dict[str, Any] | None:
|
2020-11-11 19:12:24 +00:00
|
|
|
"""Return OS information.
|
|
|
|
|
|
|
|
Async friendly.
|
|
|
|
"""
|
|
|
|
return hass.data.get(DATA_OS_INFO)
|
|
|
|
|
|
|
|
|
2020-05-12 22:27:34 +00:00
|
|
|
@callback
|
2022-12-02 10:18:49 +00:00
|
|
|
def get_core_info(hass: HomeAssistant) -> dict[str, Any] | None:
|
2020-08-12 06:00:38 +00:00
|
|
|
"""Return Home Assistant Core information from Supervisor.
|
2020-05-12 22:27:34 +00:00
|
|
|
|
|
|
|
Async friendly.
|
|
|
|
"""
|
2020-08-12 06:00:38 +00:00
|
|
|
return hass.data.get(DATA_CORE_INFO)
|
2018-01-10 18:48:31 +00:00
|
|
|
|
|
|
|
|
2023-05-30 20:08:45 +00:00
|
|
|
@callback
|
|
|
|
def get_issues_info(hass: HomeAssistant) -> SupervisorIssues | None:
|
|
|
|
"""Return Supervisor issues info.
|
|
|
|
|
|
|
|
Async friendly.
|
|
|
|
"""
|
|
|
|
return hass.data.get(DATA_KEY_SUPERVISOR_ISSUES)
|
|
|
|
|
|
|
|
|
2018-01-12 14:29:58 +00:00
|
|
|
@callback
|
2022-02-23 11:32:07 +00:00
|
|
|
def is_hassio(hass: HomeAssistant) -> bool:
|
2020-01-05 12:09:17 +00:00
|
|
|
"""Return true if Hass.io is loaded.
|
2018-01-12 14:29:58 +00:00
|
|
|
|
|
|
|
Async friendly.
|
|
|
|
"""
|
2022-02-23 11:32:07 +00:00
|
|
|
return DOMAIN in hass.config.components
|
2018-01-12 14:29:58 +00:00
|
|
|
|
|
|
|
|
2020-04-08 17:31:44 +00:00
|
|
|
@callback
|
2022-07-07 13:14:36 +00:00
|
|
|
def get_supervisor_ip() -> str | None:
|
2020-04-08 17:31:44 +00:00
|
|
|
"""Return the supervisor ip address."""
|
|
|
|
if "SUPERVISOR" not in os.environ:
|
|
|
|
return None
|
|
|
|
return os.environ["SUPERVISOR"].partition(":")[0]
|
|
|
|
|
|
|
|
|
2021-05-24 17:23:16 +00:00
|
|
|
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: # noqa: C901
|
2018-01-21 06:35:38 +00:00
|
|
|
"""Set up the Hass.io component."""
|
2022-02-23 11:32:07 +00:00
|
|
|
# Check local setup
|
2022-05-30 10:00:13 +00:00
|
|
|
for env in ("SUPERVISOR", "SUPERVISOR_TOKEN"):
|
2022-02-23 11:32:07 +00:00
|
|
|
if os.environ.get(env):
|
|
|
|
continue
|
|
|
|
_LOGGER.error("Missing %s environment variable", env)
|
2021-03-01 08:41:04 +00:00
|
|
|
if config_entries := hass.config_entries.async_entries(DOMAIN):
|
|
|
|
hass.async_create_task(
|
|
|
|
hass.config_entries.async_remove(config_entries[0].entry_id)
|
|
|
|
)
|
2017-04-07 05:19:08 +00:00
|
|
|
return False
|
|
|
|
|
2021-02-15 17:18:45 +00:00
|
|
|
async_load_websocket_api(hass)
|
|
|
|
|
2022-05-30 10:00:13 +00:00
|
|
|
host = os.environ["SUPERVISOR"]
|
2022-01-11 16:33:50 +00:00
|
|
|
websession = async_get_clientsession(hass)
|
2018-01-12 14:29:58 +00:00
|
|
|
hass.data[DOMAIN] = hassio = HassIO(hass.loop, websession, host)
|
2017-04-07 05:19:08 +00:00
|
|
|
|
2018-10-01 06:59:45 +00:00
|
|
|
if not await hassio.is_connected():
|
2021-09-29 07:46:05 +00:00
|
|
|
_LOGGER.warning("Not connected with the supervisor / system too busy!")
|
2017-04-07 05:19:08 +00:00
|
|
|
|
2022-07-09 20:32:57 +00:00
|
|
|
store = Store[dict[str, str]](hass, STORAGE_VERSION, STORAGE_KEY)
|
2021-10-30 14:30:13 +00:00
|
|
|
if (data := await store.async_load()) is None:
|
2018-07-23 12:14:57 +00:00
|
|
|
data = {}
|
|
|
|
|
2018-08-09 11:31:48 +00:00
|
|
|
refresh_token = None
|
2019-07-31 19:25:30 +00:00
|
|
|
if "hassio_user" in data:
|
|
|
|
user = await hass.auth.async_get_user(data["hassio_user"])
|
2018-08-15 07:56:05 +00:00
|
|
|
if user and user.refresh_tokens:
|
2018-08-09 11:31:48 +00:00
|
|
|
refresh_token = list(user.refresh_tokens.values())[0]
|
|
|
|
|
2020-01-05 12:09:17 +00:00
|
|
|
# Migrate old Hass.io users to be admin.
|
2018-11-25 17:04:48 +00:00
|
|
|
if not user.is_admin:
|
2019-07-31 19:25:30 +00:00
|
|
|
await hass.auth.async_update_user(user, group_ids=[GROUP_ID_ADMIN])
|
2018-11-25 17:04:48 +00:00
|
|
|
|
2021-06-14 16:01:18 +00:00
|
|
|
# Migrate old name
|
|
|
|
if user.name == "Hass.io":
|
2021-12-09 00:49:35 +00:00
|
|
|
await hass.auth.async_update_user(user, name=HASSIO_USER_NAME)
|
2021-06-14 16:01:18 +00:00
|
|
|
|
2018-08-09 11:31:48 +00:00
|
|
|
if refresh_token is None:
|
2021-11-29 22:01:03 +00:00
|
|
|
user = await hass.auth.async_create_system_user(
|
2021-12-09 00:49:35 +00:00
|
|
|
HASSIO_USER_NAME, group_ids=[GROUP_ID_ADMIN]
|
2021-11-29 22:01:03 +00:00
|
|
|
)
|
2018-10-01 06:59:45 +00:00
|
|
|
refresh_token = await hass.auth.async_create_refresh_token(user)
|
2019-07-31 19:25:30 +00:00
|
|
|
data["hassio_user"] = user.id
|
2018-10-01 06:59:45 +00:00
|
|
|
await store.async_save(data)
|
2018-07-23 12:14:57 +00:00
|
|
|
|
2018-05-29 06:51:08 +00:00
|
|
|
# This overrides the normal API call that would be forwarded
|
|
|
|
development_repo = config.get(DOMAIN, {}).get(CONF_FRONTEND_REPO)
|
|
|
|
if development_repo is not None:
|
|
|
|
hass.http.register_static_path(
|
2019-07-31 19:25:30 +00:00
|
|
|
"/api/hassio/app", os.path.join(development_repo, "hassio/build"), False
|
|
|
|
)
|
2018-05-29 06:51:08 +00:00
|
|
|
|
2018-02-20 23:24:31 +00:00
|
|
|
hass.http.register_view(HassIOView(host, websession))
|
2017-04-07 05:19:08 +00:00
|
|
|
|
2022-01-20 12:06:44 +00:00
|
|
|
await panel_custom.async_register_panel(
|
|
|
|
hass,
|
2020-03-18 00:54:57 +00:00
|
|
|
frontend_url_path="hassio",
|
|
|
|
webcomponent_name="hassio-main",
|
|
|
|
js_url="/api/hassio/app/entrypoint.js",
|
|
|
|
embed_iframe=True,
|
|
|
|
require_admin=True,
|
|
|
|
)
|
2017-04-27 07:57:40 +00:00
|
|
|
|
2020-01-14 22:49:56 +00:00
|
|
|
await hassio.update_hass_api(config.get("http", {}), refresh_token)
|
2017-10-13 13:45:22 +00:00
|
|
|
|
2020-06-15 22:22:53 +00:00
|
|
|
last_timezone = None
|
|
|
|
|
2024-01-08 09:08:09 +00:00
|
|
|
async def push_config(_: Event | None) -> None:
|
2019-06-10 23:05:43 +00:00
|
|
|
"""Push core config to Hass.io."""
|
2020-06-15 22:22:53 +00:00
|
|
|
nonlocal last_timezone
|
|
|
|
|
|
|
|
new_timezone = str(hass.config.time_zone)
|
|
|
|
|
|
|
|
if new_timezone == last_timezone:
|
|
|
|
return
|
|
|
|
|
|
|
|
last_timezone = new_timezone
|
|
|
|
await hassio.update_hass_timezone(new_timezone)
|
2019-06-10 23:05:43 +00:00
|
|
|
|
|
|
|
hass.bus.async_listen(EVENT_CORE_CONFIG_UPDATE, push_config)
|
|
|
|
|
2024-02-28 02:30:48 +00:00
|
|
|
push_config_task = hass.async_create_task(push_config(None), eager_start=True)
|
2017-10-04 05:52:45 +00:00
|
|
|
|
2021-12-28 13:19:14 +00:00
|
|
|
async def async_service_handler(service: ServiceCall) -> None:
|
2018-01-21 06:35:38 +00:00
|
|
|
"""Handle service calls for Hass.io."""
|
2021-09-03 22:44:01 +00:00
|
|
|
api_endpoint = MAP_SERVICE_API[service.service]
|
|
|
|
|
2018-01-10 18:48:31 +00:00
|
|
|
data = service.data.copy()
|
|
|
|
addon = data.pop(ATTR_ADDON, None)
|
2021-08-02 09:07:21 +00:00
|
|
|
slug = data.pop(ATTR_SLUG, None)
|
2018-01-10 18:48:31 +00:00
|
|
|
payload = None
|
|
|
|
|
2020-01-05 12:09:17 +00:00
|
|
|
# Pass data to Hass.io API
|
2018-01-10 18:48:31 +00:00
|
|
|
if service.service == SERVICE_ADDON_STDIN:
|
|
|
|
payload = data[ATTR_INPUT]
|
2021-09-03 22:44:01 +00:00
|
|
|
elif api_endpoint.pass_data:
|
2018-01-10 18:48:31 +00:00
|
|
|
payload = data
|
|
|
|
|
|
|
|
# Call API
|
2023-01-27 02:06:22 +00:00
|
|
|
# The exceptions are logged properly in hassio.send_command
|
|
|
|
with suppress(HassioAPIError):
|
2018-10-03 11:10:38 +00:00
|
|
|
await hassio.send_command(
|
2021-09-03 22:44:01 +00:00
|
|
|
api_endpoint.command.format(addon=addon, slug=slug),
|
2019-07-31 19:25:30 +00:00
|
|
|
payload=payload,
|
2021-09-03 22:44:01 +00:00
|
|
|
timeout=api_endpoint.timeout,
|
2018-10-03 11:10:38 +00:00
|
|
|
)
|
2018-01-12 14:29:58 +00:00
|
|
|
|
2017-10-04 05:52:45 +00:00
|
|
|
for service, settings in MAP_SERVICE_API.items():
|
|
|
|
hass.services.async_register(
|
2021-09-03 22:44:01 +00:00
|
|
|
DOMAIN, service, async_service_handler, schema=settings.schema
|
2019-07-31 19:25:30 +00:00
|
|
|
)
|
2017-10-04 05:52:45 +00:00
|
|
|
|
2023-04-20 18:56:45 +00:00
|
|
|
async def update_info_data(_: datetime | None = None) -> None:
|
2020-05-12 22:27:34 +00:00
|
|
|
"""Update last available supervisor information."""
|
2021-10-22 10:23:21 +00:00
|
|
|
|
2018-10-03 11:10:38 +00:00
|
|
|
try:
|
2021-10-22 10:23:21 +00:00
|
|
|
(
|
|
|
|
hass.data[DATA_INFO],
|
|
|
|
hass.data[DATA_HOST_INFO],
|
|
|
|
hass.data[DATA_STORE],
|
|
|
|
hass.data[DATA_CORE_INFO],
|
|
|
|
hass.data[DATA_SUPERVISOR_INFO],
|
|
|
|
hass.data[DATA_OS_INFO],
|
|
|
|
) = await asyncio.gather(
|
2024-02-28 02:30:48 +00:00
|
|
|
create_eager_task(hassio.get_info()),
|
|
|
|
create_eager_task(hassio.get_host_info()),
|
|
|
|
create_eager_task(hassio.get_store()),
|
|
|
|
create_eager_task(hassio.get_core_info()),
|
|
|
|
create_eager_task(hassio.get_supervisor_info()),
|
|
|
|
create_eager_task(hassio.get_os_info()),
|
2021-10-22 10:23:21 +00:00
|
|
|
)
|
|
|
|
|
2018-10-03 11:10:38 +00:00
|
|
|
except HassioAPIError as err:
|
2021-10-22 10:23:21 +00:00
|
|
|
_LOGGER.warning("Can't read Supervisor data: %s", err)
|
2018-01-10 18:48:31 +00:00
|
|
|
|
2023-08-28 15:21:05 +00:00
|
|
|
async_call_later(
|
2023-04-20 18:56:45 +00:00
|
|
|
hass,
|
2023-08-28 15:21:05 +00:00
|
|
|
HASSIO_UPDATE_INTERVAL,
|
2023-04-20 18:56:45 +00:00
|
|
|
HassJob(update_info_data, cancel_on_shutdown=True),
|
2019-07-31 19:25:30 +00:00
|
|
|
)
|
2018-01-10 18:48:31 +00:00
|
|
|
|
2021-10-22 10:23:21 +00:00
|
|
|
# Fetch data
|
2023-04-20 18:56:45 +00:00
|
|
|
await update_info_data()
|
2024-02-28 02:30:48 +00:00
|
|
|
await push_config_task
|
2018-01-10 18:48:31 +00:00
|
|
|
|
2023-10-23 18:26:56 +00:00
|
|
|
async def _async_stop(hass: HomeAssistant, restart: bool) -> None:
|
|
|
|
"""Stop or restart home assistant."""
|
|
|
|
if restart:
|
2018-10-01 06:59:45 +00:00
|
|
|
await hassio.restart_homeassistant()
|
2023-10-23 18:26:56 +00:00
|
|
|
else:
|
|
|
|
await hassio.stop_homeassistant()
|
2018-01-12 14:29:58 +00:00
|
|
|
|
2023-10-23 18:26:56 +00:00
|
|
|
# Set a custom handler for the homeassistant.restart and homeassistant.stop services
|
|
|
|
async_set_stop_handler(hass, _async_stop)
|
2018-01-12 14:29:58 +00:00
|
|
|
|
2018-10-03 11:10:38 +00:00
|
|
|
# Init discovery Hass.io feature
|
2019-04-19 07:43:47 +00:00
|
|
|
async_setup_discovery_view(hass, hassio)
|
2018-10-03 11:10:38 +00:00
|
|
|
|
2018-10-10 12:07:51 +00:00
|
|
|
# Init auth Hass.io feature
|
2022-07-07 13:14:36 +00:00
|
|
|
assert user is not None
|
2020-01-14 22:49:56 +00:00
|
|
|
async_setup_auth_view(hass, user)
|
2018-10-10 12:07:51 +00:00
|
|
|
|
2019-04-01 12:16:16 +00:00
|
|
|
# Init ingress Hass.io feature
|
2019-04-19 07:43:47 +00:00
|
|
|
async_setup_ingress_view(hass, host)
|
|
|
|
|
|
|
|
# Init add-on ingress panels
|
|
|
|
await async_setup_addon_panel(hass, hassio)
|
2019-04-01 12:16:16 +00:00
|
|
|
|
2022-05-25 18:39:15 +00:00
|
|
|
# Setup hardware integration for the detected board type
|
2024-02-25 13:37:09 +00:00
|
|
|
@callback
|
|
|
|
def _async_setup_hardware_integration(_: datetime | None = None) -> None:
|
|
|
|
"""Set up hardware integration for the detected board type."""
|
2022-05-25 18:39:15 +00:00
|
|
|
if (os_info := get_os_info(hass)) is None:
|
|
|
|
# os info not yet fetched from supervisor, retry later
|
2023-08-28 15:21:05 +00:00
|
|
|
async_call_later(
|
2022-05-25 18:39:15 +00:00
|
|
|
hass,
|
2023-08-28 15:21:05 +00:00
|
|
|
HASSIO_UPDATE_INTERVAL,
|
2023-05-09 16:42:04 +00:00
|
|
|
async_setup_hardware_integration_job,
|
2022-05-25 18:39:15 +00:00
|
|
|
)
|
|
|
|
return
|
|
|
|
if (board := os_info.get("board")) is None:
|
|
|
|
return
|
|
|
|
if (hw_integration := HARDWARE_INTEGRATIONS.get(board)) is None:
|
|
|
|
return
|
|
|
|
hass.async_create_task(
|
|
|
|
hass.config_entries.flow.async_init(
|
|
|
|
hw_integration, context={"source": "system"}
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2023-05-09 16:42:04 +00:00
|
|
|
async_setup_hardware_integration_job = HassJob(
|
|
|
|
_async_setup_hardware_integration, cancel_on_shutdown=True
|
|
|
|
)
|
|
|
|
|
2024-02-25 13:37:09 +00:00
|
|
|
_async_setup_hardware_integration()
|
2022-05-25 18:39:15 +00:00
|
|
|
|
2021-03-01 08:41:04 +00:00
|
|
|
hass.async_create_task(
|
2024-02-28 02:30:48 +00:00
|
|
|
hass.config_entries.flow.async_init(DOMAIN, context={"source": "system"}),
|
|
|
|
eager_start=True,
|
2021-03-01 08:41:04 +00:00
|
|
|
)
|
|
|
|
|
2023-03-13 08:44:20 +00:00
|
|
|
# Start listening for problems with supervisor and making issues
|
2023-04-19 06:07:38 +00:00
|
|
|
hass.data[DATA_KEY_SUPERVISOR_ISSUES] = issues = SupervisorIssues(hass, hassio)
|
2023-03-13 08:44:20 +00:00
|
|
|
await issues.setup()
|
2022-10-31 13:57:54 +00:00
|
|
|
|
2021-03-01 08:41:04 +00:00
|
|
|
return True
|
|
|
|
|
|
|
|
|
2021-04-27 14:09:59 +00:00
|
|
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
2021-03-01 08:41:04 +00:00
|
|
|
"""Set up a config entry."""
|
2022-05-18 15:58:28 +00:00
|
|
|
dev_reg = dr.async_get(hass)
|
2021-04-27 14:09:59 +00:00
|
|
|
coordinator = HassioDataUpdateCoordinator(hass, entry, dev_reg)
|
2022-04-12 09:00:55 +00:00
|
|
|
await coordinator.async_config_entry_first_refresh()
|
2023-08-02 06:29:00 +00:00
|
|
|
hass.data[ADDONS_COORDINATOR] = coordinator
|
2021-03-01 08:41:04 +00:00
|
|
|
|
2022-07-09 15:27:42 +00:00
|
|
|
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
2021-03-01 08:41:04 +00:00
|
|
|
|
2017-04-07 05:19:08 +00:00
|
|
|
return True
|
2021-03-01 08:41:04 +00:00
|
|
|
|
|
|
|
|
2021-04-27 14:09:59 +00:00
|
|
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
2021-03-01 08:41:04 +00:00
|
|
|
"""Unload a config entry."""
|
2021-04-27 14:09:59 +00:00
|
|
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
2021-03-01 08:41:04 +00:00
|
|
|
|
|
|
|
# Pop add-on data
|
|
|
|
hass.data.pop(ADDONS_COORDINATOR, None)
|
|
|
|
|
|
|
|
return unload_ok
|
|
|
|
|
|
|
|
|
|
|
|
@callback
|
|
|
|
def async_register_addons_in_dev_reg(
|
2022-05-18 15:58:28 +00:00
|
|
|
entry_id: str, dev_reg: dr.DeviceRegistry, addons: list[dict[str, Any]]
|
2021-03-01 08:41:04 +00:00
|
|
|
) -> None:
|
|
|
|
"""Register addons in the device registry."""
|
|
|
|
for addon in addons:
|
2021-10-25 11:15:00 +00:00
|
|
|
params = DeviceInfo(
|
|
|
|
identifiers={(DOMAIN, addon[ATTR_SLUG])},
|
|
|
|
model=SupervisorEntityModel.ADDON,
|
|
|
|
sw_version=addon[ATTR_VERSION],
|
|
|
|
name=addon[ATTR_NAME],
|
2022-05-18 15:58:28 +00:00
|
|
|
entry_type=dr.DeviceEntryType.SERVICE,
|
2021-10-26 08:34:02 +00:00
|
|
|
configuration_url=f"homeassistant://hassio/addon/{addon[ATTR_SLUG]}",
|
2021-10-25 11:15:00 +00:00
|
|
|
)
|
2021-03-01 17:10:51 +00:00
|
|
|
if manufacturer := addon.get(ATTR_REPOSITORY) or addon.get(ATTR_URL):
|
2021-10-25 11:15:00 +00:00
|
|
|
params[ATTR_MANUFACTURER] = manufacturer
|
|
|
|
dev_reg.async_get_or_create(config_entry_id=entry_id, **params)
|
2021-03-01 08:41:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
@callback
|
|
|
|
def async_register_os_in_dev_reg(
|
2022-05-18 15:58:28 +00:00
|
|
|
entry_id: str, dev_reg: dr.DeviceRegistry, os_dict: dict[str, Any]
|
2021-03-01 08:41:04 +00:00
|
|
|
) -> None:
|
|
|
|
"""Register OS in the device registry."""
|
2021-10-25 11:15:00 +00:00
|
|
|
params = DeviceInfo(
|
|
|
|
identifiers={(DOMAIN, "OS")},
|
|
|
|
manufacturer="Home Assistant",
|
|
|
|
model=SupervisorEntityModel.OS,
|
|
|
|
sw_version=os_dict[ATTR_VERSION],
|
|
|
|
name="Home Assistant Operating System",
|
2022-05-18 15:58:28 +00:00
|
|
|
entry_type=dr.DeviceEntryType.SERVICE,
|
2021-10-25 11:15:00 +00:00
|
|
|
)
|
|
|
|
dev_reg.async_get_or_create(config_entry_id=entry_id, **params)
|
2021-03-01 08:41:04 +00:00
|
|
|
|
|
|
|
|
2023-03-13 14:39:49 +00:00
|
|
|
@callback
|
|
|
|
def async_register_host_in_dev_reg(
|
|
|
|
entry_id: str,
|
|
|
|
dev_reg: dr.DeviceRegistry,
|
|
|
|
) -> None:
|
|
|
|
"""Register host in the device registry."""
|
|
|
|
params = DeviceInfo(
|
|
|
|
identifiers={(DOMAIN, "host")},
|
|
|
|
manufacturer="Home Assistant",
|
|
|
|
model=SupervisorEntityModel.HOST,
|
|
|
|
name="Home Assistant Host",
|
|
|
|
entry_type=dr.DeviceEntryType.SERVICE,
|
|
|
|
)
|
|
|
|
dev_reg.async_get_or_create(config_entry_id=entry_id, **params)
|
|
|
|
|
|
|
|
|
2022-03-22 11:21:12 +00:00
|
|
|
@callback
|
|
|
|
def async_register_core_in_dev_reg(
|
|
|
|
entry_id: str,
|
2022-05-18 15:58:28 +00:00
|
|
|
dev_reg: dr.DeviceRegistry,
|
2022-03-22 11:21:12 +00:00
|
|
|
core_dict: dict[str, Any],
|
|
|
|
) -> None:
|
|
|
|
"""Register OS in the device registry."""
|
|
|
|
params = DeviceInfo(
|
|
|
|
identifiers={(DOMAIN, "core")},
|
|
|
|
manufacturer="Home Assistant",
|
|
|
|
model=SupervisorEntityModel.CORE,
|
|
|
|
sw_version=core_dict[ATTR_VERSION],
|
|
|
|
name="Home Assistant Core",
|
2022-05-18 15:58:28 +00:00
|
|
|
entry_type=dr.DeviceEntryType.SERVICE,
|
2022-03-22 11:21:12 +00:00
|
|
|
)
|
|
|
|
dev_reg.async_get_or_create(config_entry_id=entry_id, **params)
|
|
|
|
|
|
|
|
|
|
|
|
@callback
|
|
|
|
def async_register_supervisor_in_dev_reg(
|
|
|
|
entry_id: str,
|
2022-05-18 15:58:28 +00:00
|
|
|
dev_reg: dr.DeviceRegistry,
|
2022-03-22 11:21:12 +00:00
|
|
|
supervisor_dict: dict[str, Any],
|
|
|
|
) -> None:
|
|
|
|
"""Register OS in the device registry."""
|
|
|
|
params = DeviceInfo(
|
|
|
|
identifiers={(DOMAIN, "supervisor")},
|
|
|
|
manufacturer="Home Assistant",
|
|
|
|
model=SupervisorEntityModel.SUPERVIOSR,
|
|
|
|
sw_version=supervisor_dict[ATTR_VERSION],
|
|
|
|
name="Home Assistant Supervisor",
|
2022-05-18 15:58:28 +00:00
|
|
|
entry_type=dr.DeviceEntryType.SERVICE,
|
2022-03-22 11:21:12 +00:00
|
|
|
)
|
|
|
|
dev_reg.async_get_or_create(config_entry_id=entry_id, **params)
|
|
|
|
|
|
|
|
|
2021-03-01 08:41:04 +00:00
|
|
|
@callback
|
2022-05-18 15:58:28 +00:00
|
|
|
def async_remove_addons_from_dev_reg(
|
|
|
|
dev_reg: dr.DeviceRegistry, addons: set[str]
|
|
|
|
) -> None:
|
2021-03-01 08:41:04 +00:00
|
|
|
"""Remove addons from the device registry."""
|
|
|
|
for addon_slug in addons:
|
2023-07-13 17:39:25 +00:00
|
|
|
if dev := dev_reg.async_get_device(identifiers={(DOMAIN, addon_slug)}):
|
2021-03-01 08:41:04 +00:00
|
|
|
dev_reg.async_remove_device(dev.id)
|
|
|
|
|
|
|
|
|
2024-01-29 09:30:19 +00:00
|
|
|
class HassioDataUpdateCoordinator(DataUpdateCoordinator): # pylint: disable=hass-enforce-coordinator-module
|
2021-03-01 08:41:04 +00:00
|
|
|
"""Class to retrieve Hass.io status."""
|
|
|
|
|
|
|
|
def __init__(
|
2022-05-18 15:58:28 +00:00
|
|
|
self, hass: HomeAssistant, config_entry: ConfigEntry, dev_reg: dr.DeviceRegistry
|
2021-03-01 08:41:04 +00:00
|
|
|
) -> None:
|
|
|
|
"""Initialize coordinator."""
|
|
|
|
super().__init__(
|
|
|
|
hass,
|
|
|
|
_LOGGER,
|
|
|
|
name=DOMAIN,
|
2022-04-04 15:34:06 +00:00
|
|
|
update_interval=HASSIO_UPDATE_INTERVAL,
|
2023-10-25 13:32:43 +00:00
|
|
|
# We don't want an immediate refresh since we want to avoid
|
|
|
|
# fetching the container stats right away and avoid hammering
|
|
|
|
# the Supervisor API on startup
|
|
|
|
request_refresh_debouncer=Debouncer(
|
|
|
|
hass, _LOGGER, cooldown=REQUEST_REFRESH_DELAY, immediate=False
|
|
|
|
),
|
2021-03-01 08:41:04 +00:00
|
|
|
)
|
2022-03-22 11:21:12 +00:00
|
|
|
self.hassio: HassIO = hass.data[DOMAIN]
|
2021-03-01 08:41:04 +00:00
|
|
|
self.data = {}
|
|
|
|
self.entry_id = config_entry.entry_id
|
|
|
|
self.dev_reg = dev_reg
|
2022-04-07 11:34:20 +00:00
|
|
|
self.is_hass_os = (get_info(self.hass) or {}).get("hassos") is not None
|
2023-10-22 16:40:48 +00:00
|
|
|
self._container_updates: defaultdict[str, dict[str, set[str]]] = defaultdict(
|
|
|
|
lambda: defaultdict(set)
|
|
|
|
)
|
2021-03-01 08:41:04 +00:00
|
|
|
|
2021-03-18 08:25:40 +00:00
|
|
|
async def _async_update_data(self) -> dict[str, Any]:
|
2021-03-01 08:41:04 +00:00
|
|
|
"""Update data via library."""
|
2023-10-06 10:14:48 +00:00
|
|
|
is_first_update = not self.data
|
|
|
|
|
2022-04-04 15:34:06 +00:00
|
|
|
try:
|
2023-10-06 10:14:48 +00:00
|
|
|
await self.force_data_refresh(is_first_update)
|
2022-04-04 15:34:06 +00:00
|
|
|
except HassioAPIError as err:
|
|
|
|
raise UpdateFailed(f"Error on Supervisor API: {err}") from err
|
|
|
|
|
2022-07-07 13:14:36 +00:00
|
|
|
new_data: dict[str, Any] = {}
|
2022-11-29 18:22:36 +00:00
|
|
|
supervisor_info = get_supervisor_info(self.hass) or {}
|
2023-05-30 20:08:45 +00:00
|
|
|
addons_info = get_addons_info(self.hass) or {}
|
2021-10-22 10:23:21 +00:00
|
|
|
addons_stats = get_addons_stats(self.hass)
|
2022-03-22 11:21:12 +00:00
|
|
|
addons_changelogs = get_addons_changelogs(self.hass)
|
2022-12-02 10:18:49 +00:00
|
|
|
store_data = get_store(self.hass) or {}
|
2021-05-31 12:06:11 +00:00
|
|
|
|
|
|
|
repositories = {
|
|
|
|
repo[ATTR_SLUG]: repo[ATTR_NAME]
|
|
|
|
for repo in store_data.get("repositories", [])
|
|
|
|
}
|
2021-03-01 08:41:04 +00:00
|
|
|
|
2021-10-22 10:23:21 +00:00
|
|
|
new_data[DATA_KEY_ADDONS] = {
|
2021-05-31 12:06:11 +00:00
|
|
|
addon[ATTR_SLUG]: {
|
|
|
|
**addon,
|
2022-04-12 09:00:55 +00:00
|
|
|
**((addons_stats or {}).get(addon[ATTR_SLUG]) or {}),
|
|
|
|
ATTR_AUTO_UPDATE: (addons_info.get(addon[ATTR_SLUG]) or {}).get(
|
2022-04-01 15:31:39 +00:00
|
|
|
ATTR_AUTO_UPDATE, False
|
|
|
|
),
|
2022-03-22 11:21:12 +00:00
|
|
|
ATTR_CHANGELOG: (addons_changelogs or {}).get(addon[ATTR_SLUG]),
|
2021-05-31 12:06:11 +00:00
|
|
|
ATTR_REPOSITORY: repositories.get(
|
|
|
|
addon.get(ATTR_REPOSITORY), addon.get(ATTR_REPOSITORY, "")
|
|
|
|
),
|
|
|
|
}
|
|
|
|
for addon in supervisor_info.get("addons", [])
|
2021-03-01 08:41:04 +00:00
|
|
|
}
|
|
|
|
if self.is_hass_os:
|
2022-03-22 11:21:12 +00:00
|
|
|
new_data[DATA_KEY_OS] = get_os_info(self.hass)
|
|
|
|
|
2023-03-09 18:06:35 +00:00
|
|
|
new_data[DATA_KEY_CORE] = {
|
|
|
|
**(get_core_info(self.hass) or {}),
|
|
|
|
**get_core_stats(self.hass),
|
|
|
|
}
|
|
|
|
new_data[DATA_KEY_SUPERVISOR] = {
|
|
|
|
**supervisor_info,
|
|
|
|
**get_supervisor_stats(self.hass),
|
|
|
|
}
|
2023-03-13 14:39:49 +00:00
|
|
|
new_data[DATA_KEY_HOST] = get_host_info(self.hass) or {}
|
2021-03-01 08:41:04 +00:00
|
|
|
|
|
|
|
# If this is the initial refresh, register all addons and return the dict
|
2023-10-06 10:14:48 +00:00
|
|
|
if is_first_update:
|
2021-03-01 08:41:04 +00:00
|
|
|
async_register_addons_in_dev_reg(
|
2021-10-22 10:23:21 +00:00
|
|
|
self.entry_id, self.dev_reg, new_data[DATA_KEY_ADDONS].values()
|
2021-03-01 08:41:04 +00:00
|
|
|
)
|
2022-03-22 11:21:12 +00:00
|
|
|
async_register_core_in_dev_reg(
|
|
|
|
self.entry_id, self.dev_reg, new_data[DATA_KEY_CORE]
|
|
|
|
)
|
|
|
|
async_register_supervisor_in_dev_reg(
|
|
|
|
self.entry_id, self.dev_reg, new_data[DATA_KEY_SUPERVISOR]
|
|
|
|
)
|
2023-03-13 14:39:49 +00:00
|
|
|
async_register_host_in_dev_reg(self.entry_id, self.dev_reg)
|
2021-03-01 08:41:04 +00:00
|
|
|
if self.is_hass_os:
|
|
|
|
async_register_os_in_dev_reg(
|
2022-03-22 11:21:12 +00:00
|
|
|
self.entry_id, self.dev_reg, new_data[DATA_KEY_OS]
|
2021-03-01 08:41:04 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# Remove add-ons that are no longer installed from device registry
|
2021-06-28 11:49:58 +00:00
|
|
|
supervisor_addon_devices = {
|
|
|
|
list(device.identifiers)[0][1]
|
|
|
|
for device in self.dev_reg.devices.values()
|
|
|
|
if self.entry_id in device.config_entries
|
|
|
|
and device.model == SupervisorEntityModel.ADDON
|
|
|
|
}
|
2021-10-22 10:23:21 +00:00
|
|
|
if stale_addons := supervisor_addon_devices - set(new_data[DATA_KEY_ADDONS]):
|
2021-06-28 11:49:58 +00:00
|
|
|
async_remove_addons_from_dev_reg(self.dev_reg, stale_addons)
|
2021-03-01 08:41:04 +00:00
|
|
|
|
2022-04-07 11:34:20 +00:00
|
|
|
if not self.is_hass_os and (
|
2023-07-13 17:39:25 +00:00
|
|
|
dev := self.dev_reg.async_get_device(identifiers={(DOMAIN, "OS")})
|
2022-04-07 11:34:20 +00:00
|
|
|
):
|
|
|
|
# Remove the OS device if it exists and the installation is not hassos
|
|
|
|
self.dev_reg.async_remove_device(dev.id)
|
|
|
|
|
2021-03-01 08:41:04 +00:00
|
|
|
# If there are new add-ons, we should reload the config entry so we can
|
|
|
|
# create new devices and entities. We can return an empty dict because
|
|
|
|
# coordinator will be recreated.
|
2021-10-22 10:23:21 +00:00
|
|
|
if self.data and set(new_data[DATA_KEY_ADDONS]) - set(
|
|
|
|
self.data[DATA_KEY_ADDONS]
|
|
|
|
):
|
2021-03-01 08:41:04 +00:00
|
|
|
self.hass.async_create_task(
|
|
|
|
self.hass.config_entries.async_reload(self.entry_id)
|
|
|
|
)
|
|
|
|
return {}
|
|
|
|
|
|
|
|
return new_data
|
2022-03-22 11:21:12 +00:00
|
|
|
|
|
|
|
async def force_info_update_supervisor(self) -> None:
|
|
|
|
"""Force update of the supervisor info."""
|
|
|
|
self.hass.data[DATA_SUPERVISOR_INFO] = await self.hassio.get_supervisor_info()
|
|
|
|
await self.async_refresh()
|
2022-04-04 15:34:06 +00:00
|
|
|
|
2023-10-06 10:14:48 +00:00
|
|
|
async def force_data_refresh(self, first_update: bool) -> None:
|
2022-04-04 15:34:06 +00:00
|
|
|
"""Force update of the addon info."""
|
2023-10-22 16:40:48 +00:00
|
|
|
container_updates = self._container_updates
|
|
|
|
|
2023-10-06 10:14:48 +00:00
|
|
|
data = self.hass.data
|
|
|
|
hassio = self.hassio
|
2023-10-22 16:40:48 +00:00
|
|
|
updates = {
|
|
|
|
DATA_INFO: hassio.get_info(),
|
|
|
|
DATA_CORE_INFO: hassio.get_core_info(),
|
|
|
|
DATA_SUPERVISOR_INFO: hassio.get_supervisor_info(),
|
|
|
|
DATA_OS_INFO: hassio.get_os_info(),
|
|
|
|
}
|
2023-10-25 13:32:43 +00:00
|
|
|
if CONTAINER_STATS in container_updates[CORE_CONTAINER]:
|
2023-10-22 16:40:48 +00:00
|
|
|
updates[DATA_CORE_STATS] = hassio.get_core_stats()
|
2023-10-25 13:32:43 +00:00
|
|
|
if CONTAINER_STATS in container_updates[SUPERVISOR_CONTAINER]:
|
2023-10-22 16:40:48 +00:00
|
|
|
updates[DATA_SUPERVISOR_STATS] = hassio.get_supervisor_stats()
|
|
|
|
|
|
|
|
results = await asyncio.gather(*updates.values())
|
|
|
|
for key, result in zip(updates, results):
|
|
|
|
data[key] = result
|
2022-04-04 15:34:06 +00:00
|
|
|
|
2023-10-06 10:14:48 +00:00
|
|
|
_addon_data = data[DATA_SUPERVISOR_INFO].get("addons", [])
|
|
|
|
all_addons: list[str] = []
|
|
|
|
started_addons: list[str] = []
|
|
|
|
for addon in _addon_data:
|
|
|
|
slug = addon[ATTR_SLUG]
|
|
|
|
all_addons.append(slug)
|
|
|
|
if addon[ATTR_STATE] == ATTR_STARTED:
|
|
|
|
started_addons.append(slug)
|
|
|
|
#
|
|
|
|
# Update add-on info if its the first update or
|
|
|
|
# there is at least one entity that needs the data.
|
|
|
|
#
|
2023-10-22 16:40:48 +00:00
|
|
|
# When entities are added they call async_enable_container_updates
|
2023-10-06 10:14:48 +00:00
|
|
|
# to enable updates for the endpoints they need via
|
|
|
|
# async_added_to_hass. This ensures that we only update
|
|
|
|
# the data for the endpoints that are needed to avoid unnecessary
|
2023-10-22 16:40:48 +00:00
|
|
|
# API calls since otherwise we would fetch stats for all containers
|
2023-10-06 10:14:48 +00:00
|
|
|
# and throw them away.
|
|
|
|
#
|
2023-10-25 13:32:43 +00:00
|
|
|
for data_key, update_func, enabled_key, wanted_addons, needs_first_update in (
|
2023-10-06 10:14:48 +00:00
|
|
|
(
|
|
|
|
DATA_ADDONS_STATS,
|
|
|
|
self._update_addon_stats,
|
2023-10-22 16:40:48 +00:00
|
|
|
CONTAINER_STATS,
|
2023-10-06 10:14:48 +00:00
|
|
|
started_addons,
|
2023-10-25 13:32:43 +00:00
|
|
|
False,
|
2023-10-06 10:14:48 +00:00
|
|
|
),
|
|
|
|
(
|
|
|
|
DATA_ADDONS_CHANGELOGS,
|
|
|
|
self._update_addon_changelog,
|
2023-10-22 16:40:48 +00:00
|
|
|
CONTAINER_CHANGELOG,
|
2023-10-06 10:14:48 +00:00
|
|
|
all_addons,
|
2023-10-25 13:32:43 +00:00
|
|
|
True,
|
|
|
|
),
|
|
|
|
(
|
|
|
|
DATA_ADDONS_INFO,
|
|
|
|
self._update_addon_info,
|
|
|
|
CONTAINER_INFO,
|
|
|
|
all_addons,
|
|
|
|
True,
|
2023-10-06 10:14:48 +00:00
|
|
|
),
|
|
|
|
):
|
2023-10-22 16:40:48 +00:00
|
|
|
container_data: dict[str, Any] = data.setdefault(data_key, {})
|
|
|
|
container_data.update(
|
2023-10-06 10:14:48 +00:00
|
|
|
dict(
|
|
|
|
await asyncio.gather(
|
|
|
|
*[
|
|
|
|
update_func(slug)
|
|
|
|
for slug in wanted_addons
|
2023-10-25 13:32:43 +00:00
|
|
|
if (first_update and needs_first_update)
|
|
|
|
or enabled_key in container_updates[slug]
|
2023-10-06 10:14:48 +00:00
|
|
|
]
|
|
|
|
)
|
|
|
|
)
|
2022-04-04 15:34:06 +00:00
|
|
|
)
|
|
|
|
|
2023-10-06 10:14:48 +00:00
|
|
|
async def _update_addon_stats(self, slug: str) -> tuple[str, dict[str, Any] | None]:
|
2022-04-04 15:34:06 +00:00
|
|
|
"""Update single addon stats."""
|
2022-04-12 09:00:55 +00:00
|
|
|
try:
|
|
|
|
stats = await self.hassio.get_addon_stats(slug)
|
|
|
|
return (slug, stats)
|
|
|
|
except HassioAPIError as err:
|
|
|
|
_LOGGER.warning("Could not fetch stats for %s: %s", slug, err)
|
|
|
|
return (slug, None)
|
2022-04-04 15:34:06 +00:00
|
|
|
|
2023-10-06 10:14:48 +00:00
|
|
|
async def _update_addon_changelog(self, slug: str) -> tuple[str, str | None]:
|
2022-04-04 15:34:06 +00:00
|
|
|
"""Return the changelog for an add-on."""
|
2022-04-12 09:00:55 +00:00
|
|
|
try:
|
|
|
|
changelog = await self.hassio.get_addon_changelog(slug)
|
|
|
|
return (slug, changelog)
|
|
|
|
except HassioAPIError as err:
|
|
|
|
_LOGGER.warning("Could not fetch changelog for %s: %s", slug, err)
|
|
|
|
return (slug, None)
|
2022-04-04 15:34:06 +00:00
|
|
|
|
2023-10-06 10:14:48 +00:00
|
|
|
async def _update_addon_info(self, slug: str) -> tuple[str, dict[str, Any] | None]:
|
2022-04-04 15:34:06 +00:00
|
|
|
"""Return the info for an add-on."""
|
2022-04-12 09:00:55 +00:00
|
|
|
try:
|
|
|
|
info = await self.hassio.get_addon_info(slug)
|
|
|
|
return (slug, info)
|
|
|
|
except HassioAPIError as err:
|
|
|
|
_LOGGER.warning("Could not fetch info for %s: %s", slug, err)
|
|
|
|
return (slug, None)
|
2022-04-15 16:31:02 +00:00
|
|
|
|
2023-10-06 10:14:48 +00:00
|
|
|
@callback
|
2023-10-22 16:40:48 +00:00
|
|
|
def async_enable_container_updates(
|
2023-10-06 10:14:48 +00:00
|
|
|
self, slug: str, entity_id: str, types: set[str]
|
|
|
|
) -> CALLBACK_TYPE:
|
|
|
|
"""Enable updates for an add-on."""
|
2023-10-22 16:40:48 +00:00
|
|
|
enabled_updates = self._container_updates[slug]
|
2023-10-06 10:14:48 +00:00
|
|
|
for key in types:
|
|
|
|
enabled_updates[key].add(entity_id)
|
|
|
|
|
|
|
|
@callback
|
2024-01-08 09:08:09 +00:00
|
|
|
def _remove() -> None:
|
2023-10-06 10:14:48 +00:00
|
|
|
for key in types:
|
|
|
|
enabled_updates[key].remove(entity_id)
|
|
|
|
|
|
|
|
return _remove
|
|
|
|
|
2022-04-15 16:31:02 +00:00
|
|
|
async def _async_refresh(
|
|
|
|
self,
|
|
|
|
log_failures: bool = True,
|
|
|
|
raise_on_auth_failed: bool = False,
|
|
|
|
scheduled: bool = False,
|
2022-11-25 10:33:03 +00:00
|
|
|
raise_on_entry_error: bool = False,
|
2022-04-15 16:31:02 +00:00
|
|
|
) -> None:
|
|
|
|
"""Refresh data."""
|
2024-02-06 21:34:53 +00:00
|
|
|
if not scheduled and not raise_on_auth_failed:
|
2022-04-15 16:31:02 +00:00
|
|
|
# Force refreshing updates for non-scheduled updates
|
2024-02-06 21:34:53 +00:00
|
|
|
# If `raise_on_auth_failed` is set, it means this is
|
|
|
|
# the first refresh and we do not want to delay
|
|
|
|
# startup or cause a timeout so we only refresh the
|
|
|
|
# updates if this is not a scheduled refresh and
|
|
|
|
# we are not doing the first refresh.
|
2022-04-15 16:31:02 +00:00
|
|
|
try:
|
|
|
|
await self.hassio.refresh_updates()
|
|
|
|
except HassioAPIError as err:
|
|
|
|
_LOGGER.warning("Error on Supervisor API: %s", err)
|
2024-02-06 21:34:53 +00:00
|
|
|
|
2022-11-25 10:33:03 +00:00
|
|
|
await super()._async_refresh(
|
|
|
|
log_failures, raise_on_auth_failed, scheduled, raise_on_entry_error
|
|
|
|
)
|