mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Explicitly pass in the config_entry in tessie coordinator (#137906)
explicitly pass in the config_entry in coordinator
This commit is contained in:
parent
4646d35054
commit
0baa6b3668
@ -69,6 +69,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: TessieConfigEntry) -> bo
|
|||||||
vin=vehicle["vin"],
|
vin=vehicle["vin"],
|
||||||
data_coordinator=TessieStateUpdateCoordinator(
|
data_coordinator=TessieStateUpdateCoordinator(
|
||||||
hass,
|
hass,
|
||||||
|
entry,
|
||||||
api_key=api_key,
|
api_key=api_key,
|
||||||
vin=vehicle["vin"],
|
vin=vehicle["vin"],
|
||||||
data=vehicle["last_state"],
|
data=vehicle["last_state"],
|
||||||
@ -127,8 +128,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: TessieConfigEntry) -> bo
|
|||||||
TessieEnergyData(
|
TessieEnergyData(
|
||||||
api=api,
|
api=api,
|
||||||
id=site_id,
|
id=site_id,
|
||||||
live_coordinator=TessieEnergySiteLiveCoordinator(hass, api),
|
live_coordinator=TessieEnergySiteLiveCoordinator(
|
||||||
info_coordinator=TessieEnergySiteInfoCoordinator(hass, api),
|
hass, entry, api
|
||||||
|
),
|
||||||
|
info_coordinator=TessieEnergySiteInfoCoordinator(
|
||||||
|
hass, entry, api
|
||||||
|
),
|
||||||
device=DeviceInfo(
|
device=DeviceInfo(
|
||||||
identifiers={(DOMAIN, str(site_id))},
|
identifiers={(DOMAIN, str(site_id))},
|
||||||
manufacturer="Tesla",
|
manufacturer="Tesla",
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
"""Tessie Data Coordinator."""
|
"""Tessie Data Coordinator."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
import logging
|
import logging
|
||||||
from typing import Any
|
from typing import TYPE_CHECKING, Any
|
||||||
|
|
||||||
from aiohttp import ClientResponseError
|
from aiohttp import ClientResponseError
|
||||||
from tesla_fleet_api import EnergySpecific
|
from tesla_fleet_api import EnergySpecific
|
||||||
@ -15,6 +17,9 @@ from homeassistant.exceptions import ConfigEntryAuthFailed
|
|||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from . import TessieConfigEntry
|
||||||
|
|
||||||
from .const import TessieStatus
|
from .const import TessieStatus
|
||||||
|
|
||||||
# This matches the update interval Tessie performs server side
|
# This matches the update interval Tessie performs server side
|
||||||
@ -40,9 +45,12 @@ def flatten(data: dict[str, Any], parent: str | None = None) -> dict[str, Any]:
|
|||||||
class TessieStateUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
class TessieStateUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
||||||
"""Class to manage fetching data from the Tessie API."""
|
"""Class to manage fetching data from the Tessie API."""
|
||||||
|
|
||||||
|
config_entry: TessieConfigEntry
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
|
config_entry: TessieConfigEntry,
|
||||||
api_key: str,
|
api_key: str,
|
||||||
vin: str,
|
vin: str,
|
||||||
data: dict[str, Any],
|
data: dict[str, Any],
|
||||||
@ -51,6 +59,7 @@ class TessieStateUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
super().__init__(
|
super().__init__(
|
||||||
hass,
|
hass,
|
||||||
_LOGGER,
|
_LOGGER,
|
||||||
|
config_entry=config_entry,
|
||||||
name="Tessie",
|
name="Tessie",
|
||||||
update_interval=timedelta(seconds=TESSIE_SYNC_INTERVAL),
|
update_interval=timedelta(seconds=TESSIE_SYNC_INTERVAL),
|
||||||
)
|
)
|
||||||
@ -90,11 +99,16 @@ class TessieStateUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
class TessieEnergySiteLiveCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
class TessieEnergySiteLiveCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
||||||
"""Class to manage fetching energy site live status from the Tessie API."""
|
"""Class to manage fetching energy site live status from the Tessie API."""
|
||||||
|
|
||||||
def __init__(self, hass: HomeAssistant, api: EnergySpecific) -> None:
|
config_entry: TessieConfigEntry
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self, hass: HomeAssistant, config_entry: TessieConfigEntry, api: EnergySpecific
|
||||||
|
) -> None:
|
||||||
"""Initialize Tessie Energy Site Live coordinator."""
|
"""Initialize Tessie Energy Site Live coordinator."""
|
||||||
super().__init__(
|
super().__init__(
|
||||||
hass,
|
hass,
|
||||||
_LOGGER,
|
_LOGGER,
|
||||||
|
config_entry=config_entry,
|
||||||
name="Tessie Energy Site Live",
|
name="Tessie Energy Site Live",
|
||||||
update_interval=TESSIE_FLEET_API_SYNC_INTERVAL,
|
update_interval=TESSIE_FLEET_API_SYNC_INTERVAL,
|
||||||
)
|
)
|
||||||
@ -121,11 +135,16 @@ class TessieEnergySiteLiveCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
class TessieEnergySiteInfoCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
class TessieEnergySiteInfoCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
||||||
"""Class to manage fetching energy site info from the Tessie API."""
|
"""Class to manage fetching energy site info from the Tessie API."""
|
||||||
|
|
||||||
def __init__(self, hass: HomeAssistant, api: EnergySpecific) -> None:
|
config_entry: TessieConfigEntry
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self, hass: HomeAssistant, config_entry: TessieConfigEntry, api: EnergySpecific
|
||||||
|
) -> None:
|
||||||
"""Initialize Tessie Energy Info coordinator."""
|
"""Initialize Tessie Energy Info coordinator."""
|
||||||
super().__init__(
|
super().__init__(
|
||||||
hass,
|
hass,
|
||||||
_LOGGER,
|
_LOGGER,
|
||||||
|
config_entry=config_entry,
|
||||||
name="Tessie Energy Site Info",
|
name="Tessie Energy Site Info",
|
||||||
update_interval=TESSIE_FLEET_API_SYNC_INTERVAL,
|
update_interval=TESSIE_FLEET_API_SYNC_INTERVAL,
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user