mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 09:17:53 +00:00
Explicitly pass config_entry to coordinator in lamarzocco (#129434)
* Update __init__.py * Update coordinator.py * Update coordinator.py * ruff * Update coordinator.py * move type to coordinator
This commit is contained in:
parent
fbe8b6c34d
commit
484e5cb3e8
@ -26,7 +26,7 @@ from homeassistant.helpers import issue_registry as ir
|
||||
from homeassistant.helpers.httpx_client import get_async_client
|
||||
|
||||
from .const import CONF_USE_BLUETOOTH, DOMAIN
|
||||
from .coordinator import LaMarzoccoUpdateCoordinator
|
||||
from .coordinator import LaMarzoccoConfigEntry, LaMarzoccoUpdateCoordinator
|
||||
|
||||
PLATFORMS = [
|
||||
Platform.BINARY_SENSOR,
|
||||
@ -41,8 +41,6 @@ PLATFORMS = [
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
type LaMarzoccoConfigEntry = ConfigEntry[LaMarzoccoUpdateCoordinator]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: LaMarzoccoConfigEntry) -> bool:
|
||||
"""Set up La Marzocco as config entry."""
|
||||
@ -103,6 +101,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: LaMarzoccoConfigEntry) -
|
||||
|
||||
coordinator = LaMarzoccoUpdateCoordinator(
|
||||
hass=hass,
|
||||
entry=entry,
|
||||
local_client=local_client,
|
||||
cloud_client=cloud_client,
|
||||
bluetooth_client=bluetooth_client,
|
||||
|
@ -14,7 +14,7 @@ from homeassistant.const import EntityCategory
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import LaMarzoccoConfigEntry
|
||||
from .coordinator import LaMarzoccoConfigEntry
|
||||
from .entity import LaMarzoccoEntity, LaMarzoccoEntityDescription
|
||||
|
||||
|
||||
|
@ -12,8 +12,8 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import LaMarzoccoConfigEntry
|
||||
from .const import DOMAIN
|
||||
from .coordinator import LaMarzoccoConfigEntry
|
||||
from .entity import LaMarzoccoEntity, LaMarzoccoEntityDescription
|
||||
|
||||
|
||||
|
@ -10,8 +10,7 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
from . import LaMarzoccoConfigEntry
|
||||
from .coordinator import LaMarzoccoUpdateCoordinator
|
||||
from .coordinator import LaMarzoccoConfigEntry, LaMarzoccoUpdateCoordinator
|
||||
from .entity import LaMarzoccoBaseEntity
|
||||
|
||||
CALENDAR_KEY = "auto_on_off_schedule"
|
||||
|
@ -1,5 +1,7 @@
|
||||
"""Coordinator for La Marzocco API."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Callable, Coroutine
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
@ -26,21 +28,30 @@ STATISTICS_UPDATE_INTERVAL = 300
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
type LaMarzoccoConfigEntry = ConfigEntry[LaMarzoccoUpdateCoordinator]
|
||||
|
||||
|
||||
class LaMarzoccoUpdateCoordinator(DataUpdateCoordinator[None]):
|
||||
"""Class to handle fetching data from the La Marzocco API centrally."""
|
||||
|
||||
config_entry: ConfigEntry
|
||||
config_entry: LaMarzoccoConfigEntry
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
hass: HomeAssistant,
|
||||
entry: LaMarzoccoConfigEntry,
|
||||
cloud_client: LaMarzoccoCloudClient,
|
||||
local_client: LaMarzoccoLocalClient | None,
|
||||
bluetooth_client: LaMarzoccoBluetoothClient | None,
|
||||
) -> None:
|
||||
"""Initialize coordinator."""
|
||||
super().__init__(hass, _LOGGER, name=DOMAIN, update_interval=SCAN_INTERVAL)
|
||||
super().__init__(
|
||||
hass,
|
||||
_LOGGER,
|
||||
config_entry=entry,
|
||||
name=DOMAIN,
|
||||
update_interval=SCAN_INTERVAL,
|
||||
)
|
||||
self.local_connection_configured = local_client is not None
|
||||
|
||||
assert self.config_entry.unique_id
|
||||
|
@ -10,7 +10,7 @@ from lmcloud.const import FirmwareType
|
||||
from homeassistant.components.diagnostics import async_redact_data
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import LaMarzoccoConfigEntry
|
||||
from .coordinator import LaMarzoccoConfigEntry
|
||||
|
||||
TO_REDACT = {
|
||||
"serial_number",
|
||||
|
@ -31,9 +31,8 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import LaMarzoccoConfigEntry
|
||||
from .const import DOMAIN
|
||||
from .coordinator import LaMarzoccoUpdateCoordinator
|
||||
from .coordinator import LaMarzoccoConfigEntry, LaMarzoccoUpdateCoordinator
|
||||
from .entity import LaMarzoccoEntity, LaMarzoccoEntityDescription
|
||||
|
||||
|
||||
|
@ -15,8 +15,8 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import LaMarzoccoConfigEntry
|
||||
from .const import DOMAIN
|
||||
from .coordinator import LaMarzoccoConfigEntry
|
||||
from .entity import LaMarzoccoEntity, LaMarzoccoEntityDescription
|
||||
|
||||
STEAM_LEVEL_HA_TO_LM = {
|
||||
|
@ -16,7 +16,7 @@ from homeassistant.const import EntityCategory, UnitOfTemperature, UnitOfTime
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import LaMarzoccoConfigEntry
|
||||
from .coordinator import LaMarzoccoConfigEntry
|
||||
from .entity import LaMarzoccoEntity, LaMarzoccoEntityDescription
|
||||
|
||||
|
||||
|
@ -15,9 +15,8 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import LaMarzoccoConfigEntry
|
||||
from .const import DOMAIN
|
||||
from .coordinator import LaMarzoccoUpdateCoordinator
|
||||
from .coordinator import LaMarzoccoConfigEntry, LaMarzoccoUpdateCoordinator
|
||||
from .entity import LaMarzoccoBaseEntity, LaMarzoccoEntity, LaMarzoccoEntityDescription
|
||||
|
||||
|
||||
|
@ -17,8 +17,8 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import LaMarzoccoConfigEntry
|
||||
from .const import DOMAIN
|
||||
from .coordinator import LaMarzoccoConfigEntry
|
||||
from .entity import LaMarzoccoEntity, LaMarzoccoEntityDescription
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user