diff --git a/homeassistant/components/heos/__init__.py b/homeassistant/components/heos/__init__.py index 10fd2bfcff3..b119ea83064 100644 --- a/homeassistant/components/heos/__init__.py +++ b/homeassistant/components/heos/__init__.py @@ -4,7 +4,6 @@ from __future__ import annotations from datetime import timedelta -from homeassistant.config_entries import ConfigEntry from homeassistant.const import Platform from homeassistant.core import HomeAssistant from homeassistant.helpers import device_registry as dr @@ -13,7 +12,7 @@ from homeassistant.helpers.typing import ConfigType from . import services from .const import DOMAIN -from .coordinator import HeosCoordinator +from .coordinator import HeosConfigEntry, HeosCoordinator PLATFORMS = [Platform.MEDIA_PLAYER] @@ -21,8 +20,6 @@ MIN_UPDATE_SOURCES = timedelta(seconds=1) CONFIG_SCHEMA = cv.empty_config_schema(DOMAIN) -type HeosConfigEntry = ConfigEntry[HeosCoordinator] - async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the HEOS component.""" diff --git a/homeassistant/components/heos/config_flow.py b/homeassistant/components/heos/config_flow.py index 18b8f1f7918..db2abee559c 100644 --- a/homeassistant/components/heos/config_flow.py +++ b/homeassistant/components/heos/config_flow.py @@ -9,7 +9,6 @@ from pyheos import CommandAuthenticationError, Heos, HeosError, HeosOptions import voluptuous as vol from homeassistant.config_entries import ( - ConfigEntry, ConfigEntryState, ConfigFlow, ConfigFlowResult, @@ -23,8 +22,8 @@ from homeassistant.helpers.service_info.ssdp import ( SsdpServiceInfo, ) -from . import HeosConfigEntry from .const import DOMAIN +from .coordinator import HeosConfigEntry _LOGGER = logging.getLogger(__name__) @@ -107,7 +106,7 @@ class HeosFlowHandler(ConfigFlow, domain=DOMAIN): @staticmethod @callback - def async_get_options_flow(config_entry: ConfigEntry) -> OptionsFlow: + def async_get_options_flow(config_entry: HeosConfigEntry) -> OptionsFlow: """Create the options flow.""" return HeosOptionsFlowHandler() diff --git a/homeassistant/components/heos/coordinator.py b/homeassistant/components/heos/coordinator.py index 9fc3bb2460f..1cd75049f16 100644 --- a/homeassistant/components/heos/coordinator.py +++ b/homeassistant/components/heos/coordinator.py @@ -33,11 +33,13 @@ from .const import DOMAIN _LOGGER = logging.getLogger(__name__) +type HeosConfigEntry = ConfigEntry[HeosCoordinator] + class HeosCoordinator(DataUpdateCoordinator[None]): """Define the HEOS integration coordinator.""" - def __init__(self, hass: HomeAssistant, config_entry: ConfigEntry) -> None: + def __init__(self, hass: HomeAssistant, config_entry: HeosConfigEntry) -> None: """Set up the coordinator and set in config_entry.""" self.host: str = config_entry.data[CONF_HOST] credentials: Credentials | None = None diff --git a/homeassistant/components/heos/media_player.py b/homeassistant/components/heos/media_player.py index 547f932c21f..bee03018f7c 100644 --- a/homeassistant/components/heos/media_player.py +++ b/homeassistant/components/heos/media_player.py @@ -38,9 +38,8 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.update_coordinator import CoordinatorEntity from homeassistant.util.dt import utcnow -from . import HeosConfigEntry from .const import DOMAIN as HEOS_DOMAIN -from .coordinator import HeosCoordinator +from .coordinator import HeosConfigEntry, HeosCoordinator PARALLEL_UPDATES = 0 diff --git a/homeassistant/components/heos/services.py b/homeassistant/components/heos/services.py index 5a0105f830e..c447befbb30 100644 --- a/homeassistant/components/heos/services.py +++ b/homeassistant/components/heos/services.py @@ -1,6 +1,7 @@ """Services for the HEOS integration.""" import logging +from typing import cast from pyheos import CommandAuthenticationError, Heos, HeosError import voluptuous as vol @@ -17,6 +18,7 @@ from .const import ( SERVICE_SIGN_IN, SERVICE_SIGN_OUT, ) +from .coordinator import HeosConfigEntry _LOGGER = logging.getLogger(__name__) @@ -59,7 +61,10 @@ def _get_controller(hass: HomeAssistant) -> Heos: translation_key="sign_in_out_deprecated", ) - entry = hass.config_entries.async_entry_for_domain_unique_id(DOMAIN, DOMAIN) + entry = cast( + HeosConfigEntry, + hass.config_entries.async_entry_for_domain_unique_id(DOMAIN, DOMAIN), + ) if not entry or not entry.state == ConfigEntryState.LOADED: raise HomeAssistantError( translation_domain=DOMAIN, translation_key="integration_not_loaded"