mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Use typed ConfigEntry throughout HEOS (#136569)
This commit is contained in:
parent
c9218b91c1
commit
b467bb2813
@ -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."""
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user