Use entry.runtime_data in Tessie (#118287)
parent
3ba3e3135e
commit
b71f6a2b7d
|
@ -12,9 +12,8 @@ from homeassistant.core import HomeAssistant
|
|||
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
||||
from .const import DOMAIN
|
||||
from .coordinator import TessieStateUpdateCoordinator
|
||||
from .models import TessieVehicle
|
||||
from .models import TessieData
|
||||
|
||||
PLATFORMS = [
|
||||
Platform.BINARY_SENSOR,
|
||||
|
@ -33,8 +32,10 @@ PLATFORMS = [
|
|||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
type TessieConfigEntry = ConfigEntry[TessieData]
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: TessieConfigEntry) -> bool:
|
||||
"""Set up Tessie config."""
|
||||
api_key = entry.data[CONF_ACCESS_TOKEN]
|
||||
|
||||
|
@ -52,28 +53,23 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
except ClientError as e:
|
||||
raise ConfigEntryNotReady from e
|
||||
|
||||
data = [
|
||||
TessieVehicle(
|
||||
state_coordinator=TessieStateUpdateCoordinator(
|
||||
hass,
|
||||
api_key=api_key,
|
||||
vin=vehicle["vin"],
|
||||
data=vehicle["last_state"],
|
||||
)
|
||||
vehicles = [
|
||||
TessieStateUpdateCoordinator(
|
||||
hass,
|
||||
api_key=api_key,
|
||||
vin=vehicle["vin"],
|
||||
data=vehicle["last_state"],
|
||||
)
|
||||
for vehicle in vehicles["results"]
|
||||
if vehicle["last_state"] is not None
|
||||
]
|
||||
|
||||
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = data
|
||||
entry.runtime_data = TessieData(vehicles=vehicles)
|
||||
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
async def async_unload_entry(hass: HomeAssistant, entry: TessieConfigEntry) -> bool:
|
||||
"""Unload Tessie Config."""
|
||||
if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
|
||||
hass.data[DOMAIN].pop(entry.entry_id)
|
||||
|
||||
return unload_ok
|
||||
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||
|
|
|
@ -10,12 +10,12 @@ from homeassistant.components.binary_sensor import (
|
|||
BinarySensorEntity,
|
||||
BinarySensorEntityDescription,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import EntityCategory
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import DOMAIN, TessieState
|
||||
from . import TessieConfigEntry
|
||||
from .const import TessieState
|
||||
from .coordinator import TessieStateUpdateCoordinator
|
||||
from .entity import TessieEntity
|
||||
|
||||
|
@ -159,16 +159,18 @@ DESCRIPTIONS: tuple[TessieBinarySensorEntityDescription, ...] = (
|
|||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||
hass: HomeAssistant,
|
||||
entry: TessieConfigEntry,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up the Tessie binary sensor platform from a config entry."""
|
||||
data = hass.data[DOMAIN][entry.entry_id]
|
||||
data = entry.runtime_data
|
||||
|
||||
async_add_entities(
|
||||
TessieBinarySensorEntity(vehicle.state_coordinator, description)
|
||||
for vehicle in data
|
||||
TessieBinarySensorEntity(vehicle, description)
|
||||
for vehicle in data.vehicles
|
||||
for description in DESCRIPTIONS
|
||||
if description.key in vehicle.state_coordinator.data
|
||||
if description.key in vehicle.data
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -15,11 +15,10 @@ from tessie_api import (
|
|||
)
|
||||
|
||||
from homeassistant.components.button import ButtonEntity, ButtonEntityDescription
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import DOMAIN
|
||||
from . import TessieConfigEntry
|
||||
from .coordinator import TessieStateUpdateCoordinator
|
||||
from .entity import TessieEntity
|
||||
|
||||
|
@ -47,14 +46,16 @@ DESCRIPTIONS: tuple[TessieButtonEntityDescription, ...] = (
|
|||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||
hass: HomeAssistant,
|
||||
entry: TessieConfigEntry,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up the Tessie Button platform from a config entry."""
|
||||
data = hass.data[DOMAIN][entry.entry_id]
|
||||
data = entry.runtime_data
|
||||
|
||||
async_add_entities(
|
||||
TessieButtonEntity(vehicle.state_coordinator, description)
|
||||
for vehicle in data
|
||||
TessieButtonEntity(vehicle, description)
|
||||
for vehicle in data.vehicles
|
||||
for description in DESCRIPTIONS
|
||||
)
|
||||
|
||||
|
|
|
@ -17,25 +17,25 @@ from homeassistant.components.climate import (
|
|||
ClimateEntityFeature,
|
||||
HVACMode,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ATTR_TEMPERATURE, PRECISION_HALVES, UnitOfTemperature
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import DOMAIN, TessieClimateKeeper
|
||||
from . import TessieConfigEntry
|
||||
from .const import TessieClimateKeeper
|
||||
from .coordinator import TessieStateUpdateCoordinator
|
||||
from .entity import TessieEntity
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||
hass: HomeAssistant,
|
||||
entry: TessieConfigEntry,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up the Tessie Climate platform from a config entry."""
|
||||
data = hass.data[DOMAIN][entry.entry_id]
|
||||
data = entry.runtime_data
|
||||
|
||||
async_add_entities(
|
||||
TessieClimateEntity(vehicle.state_coordinator) for vehicle in data
|
||||
)
|
||||
async_add_entities(TessieClimateEntity(vehicle) for vehicle in data.vehicles)
|
||||
|
||||
|
||||
class TessieClimateEntity(TessieEntity, ClimateEntity):
|
||||
|
|
|
@ -10,10 +10,11 @@ from aiohttp import ClientConnectionError, ClientResponseError
|
|||
from tessie_api import get_state_of_all_vehicles
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_ACCESS_TOKEN
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
||||
from . import TessieConfigEntry
|
||||
from .const import DOMAIN
|
||||
|
||||
TESSIE_SCHEMA = vol.Schema({vol.Required(CONF_ACCESS_TOKEN): str})
|
||||
|
@ -29,7 +30,7 @@ class TessieConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
|
||||
def __init__(self) -> None:
|
||||
"""Initialize."""
|
||||
self._reauth_entry: ConfigEntry | None = None
|
||||
self._reauth_entry: TessieConfigEntry | None = None
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: Mapping[str, Any] | None = None
|
||||
|
|
|
@ -18,30 +18,32 @@ from homeassistant.components.cover import (
|
|||
CoverEntity,
|
||||
CoverEntityFeature,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import DOMAIN, TessieCoverStates
|
||||
from . import TessieConfigEntry
|
||||
from .const import TessieCoverStates
|
||||
from .coordinator import TessieStateUpdateCoordinator
|
||||
from .entity import TessieEntity
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||
hass: HomeAssistant,
|
||||
entry: TessieConfigEntry,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up the Tessie sensor platform from a config entry."""
|
||||
data = hass.data[DOMAIN][entry.entry_id]
|
||||
data = entry.runtime_data
|
||||
|
||||
async_add_entities(
|
||||
klass(vehicle.state_coordinator)
|
||||
klass(vehicle)
|
||||
for klass in (
|
||||
TessieWindowEntity,
|
||||
TessieChargePortEntity,
|
||||
TessieFrontTrunkEntity,
|
||||
TessieRearTrunkEntity,
|
||||
)
|
||||
for vehicle in data
|
||||
for vehicle in data.vehicles
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -4,29 +4,30 @@ from __future__ import annotations
|
|||
|
||||
from homeassistant.components.device_tracker import SourceType
|
||||
from homeassistant.components.device_tracker.config_entry import TrackerEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import StateType
|
||||
|
||||
from .const import DOMAIN
|
||||
from . import TessieConfigEntry
|
||||
from .coordinator import TessieStateUpdateCoordinator
|
||||
from .entity import TessieEntity
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||
hass: HomeAssistant,
|
||||
entry: TessieConfigEntry,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up the Tessie device tracker platform from a config entry."""
|
||||
data = hass.data[DOMAIN][entry.entry_id]
|
||||
data = entry.runtime_data
|
||||
|
||||
async_add_entities(
|
||||
klass(vehicle.state_coordinator)
|
||||
klass(vehicle)
|
||||
for klass in (
|
||||
TessieDeviceTrackerLocationEntity,
|
||||
TessieDeviceTrackerRouteEntity,
|
||||
)
|
||||
for vehicle in data
|
||||
for vehicle in data.vehicles
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -15,37 +15,39 @@ from tessie_api import (
|
|||
from homeassistant.components.automation import automations_with_entity
|
||||
from homeassistant.components.lock import ATTR_CODE, LockEntity
|
||||
from homeassistant.components.script import scripts_with_entity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ServiceValidationError
|
||||
from homeassistant.helpers import entity_registry as er, issue_registry as ir
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import TessieConfigEntry
|
||||
from .const import DOMAIN, TessieChargeCableLockStates
|
||||
from .coordinator import TessieStateUpdateCoordinator
|
||||
from .entity import TessieEntity
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||
hass: HomeAssistant,
|
||||
entry: TessieConfigEntry,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up the Tessie sensor platform from a config entry."""
|
||||
data = hass.data[DOMAIN][entry.entry_id]
|
||||
data = entry.runtime_data
|
||||
|
||||
entities = [
|
||||
klass(vehicle.state_coordinator)
|
||||
klass(vehicle)
|
||||
for klass in (TessieLockEntity, TessieCableLockEntity)
|
||||
for vehicle in data
|
||||
for vehicle in data.vehicles
|
||||
]
|
||||
|
||||
ent_reg = er.async_get(hass)
|
||||
|
||||
for vehicle in data:
|
||||
for vehicle in data.vehicles:
|
||||
entity_id = ent_reg.async_get_entity_id(
|
||||
Platform.LOCK,
|
||||
DOMAIN,
|
||||
f"{vehicle.state_coordinator.vin}-vehicle_state_speed_limit_mode_active",
|
||||
f"{vehicle.vin}-vehicle_state_speed_limit_mode_active",
|
||||
)
|
||||
if entity_id:
|
||||
entity_entry = ent_reg.async_get(entity_id)
|
||||
|
@ -53,7 +55,7 @@ async def async_setup_entry(
|
|||
if entity_entry.disabled:
|
||||
ent_reg.async_remove(entity_id)
|
||||
else:
|
||||
entities.append(TessieSpeedLimitEntity(vehicle.state_coordinator))
|
||||
entities.append(TessieSpeedLimitEntity(vehicle))
|
||||
|
||||
entity_automations = automations_with_entity(hass, entity_id)
|
||||
entity_scripts = scripts_with_entity(hass, entity_id)
|
||||
|
|
|
@ -7,11 +7,10 @@ from homeassistant.components.media_player import (
|
|||
MediaPlayerEntity,
|
||||
MediaPlayerState,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import DOMAIN
|
||||
from . import TessieConfigEntry
|
||||
from .coordinator import TessieStateUpdateCoordinator
|
||||
from .entity import TessieEntity
|
||||
|
||||
|
@ -23,12 +22,14 @@ STATES = {
|
|||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||
hass: HomeAssistant,
|
||||
entry: TessieConfigEntry,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up the Tessie Media platform from a config entry."""
|
||||
data = hass.data[DOMAIN][entry.entry_id]
|
||||
data = entry.runtime_data
|
||||
|
||||
async_add_entities(TessieMediaEntity(vehicle.state_coordinator) for vehicle in data)
|
||||
async_add_entities(TessieMediaEntity(vehicle) for vehicle in data.vehicles)
|
||||
|
||||
|
||||
class TessieMediaEntity(TessieEntity, MediaPlayerEntity):
|
||||
|
|
|
@ -8,7 +8,7 @@ from .coordinator import TessieStateUpdateCoordinator
|
|||
|
||||
|
||||
@dataclass
|
||||
class TessieVehicle:
|
||||
class TessieData:
|
||||
"""Data for the Tessie integration."""
|
||||
|
||||
state_coordinator: TessieStateUpdateCoordinator
|
||||
vehicles: list[TessieStateUpdateCoordinator]
|
||||
|
|
|
@ -13,7 +13,6 @@ from homeassistant.components.number import (
|
|||
NumberEntityDescription,
|
||||
NumberMode,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
PERCENTAGE,
|
||||
PRECISION_WHOLE,
|
||||
|
@ -23,7 +22,7 @@ from homeassistant.const import (
|
|||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import DOMAIN
|
||||
from . import TessieConfigEntry
|
||||
from .coordinator import TessieStateUpdateCoordinator
|
||||
from .entity import TessieEntity
|
||||
|
||||
|
@ -81,16 +80,18 @@ DESCRIPTIONS: tuple[TessieNumberEntityDescription, ...] = (
|
|||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||
hass: HomeAssistant,
|
||||
entry: TessieConfigEntry,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up the Tessie sensor platform from a config entry."""
|
||||
data = hass.data[DOMAIN][entry.entry_id]
|
||||
data = entry.runtime_data
|
||||
|
||||
async_add_entities(
|
||||
TessieNumberEntity(vehicle.state_coordinator, description)
|
||||
for vehicle in data
|
||||
TessieNumberEntity(vehicle, description)
|
||||
for vehicle in data.vehicles
|
||||
for description in DESCRIPTIONS
|
||||
if description.key in vehicle.state_coordinator.data
|
||||
if description.key in vehicle.data
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -5,11 +5,11 @@ from __future__ import annotations
|
|||
from tessie_api import set_seat_heat
|
||||
|
||||
from homeassistant.components.select import SelectEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import DOMAIN, TessieSeatHeaterOptions
|
||||
from . import TessieConfigEntry
|
||||
from .const import TessieSeatHeaterOptions
|
||||
from .entity import TessieEntity
|
||||
|
||||
SEAT_HEATERS = {
|
||||
|
@ -24,16 +24,18 @@ SEAT_HEATERS = {
|
|||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||
hass: HomeAssistant,
|
||||
entry: TessieConfigEntry,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up the Tessie select platform from a config entry."""
|
||||
data = hass.data[DOMAIN][entry.entry_id]
|
||||
data = entry.runtime_data
|
||||
|
||||
async_add_entities(
|
||||
TessieSeatHeaterSelectEntity(vehicle.state_coordinator, key)
|
||||
for vehicle in data
|
||||
TessieSeatHeaterSelectEntity(vehicle, key)
|
||||
for vehicle in data.vehicles
|
||||
for key in SEAT_HEATERS
|
||||
if key in vehicle.state_coordinator.data
|
||||
if key in vehicle.data
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ from homeassistant.components.sensor import (
|
|||
SensorEntityDescription,
|
||||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
PERCENTAGE,
|
||||
EntityCategory,
|
||||
|
@ -33,7 +32,8 @@ from homeassistant.helpers.typing import StateType
|
|||
from homeassistant.util import dt as dt_util
|
||||
from homeassistant.util.variance import ignore_variance
|
||||
|
||||
from .const import DOMAIN, TessieChargeStates
|
||||
from . import TessieConfigEntry
|
||||
from .const import TessieChargeStates
|
||||
from .coordinator import TessieStateUpdateCoordinator
|
||||
from .entity import TessieEntity
|
||||
|
||||
|
@ -259,14 +259,16 @@ DESCRIPTIONS: tuple[TessieSensorEntityDescription, ...] = (
|
|||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||
hass: HomeAssistant,
|
||||
entry: TessieConfigEntry,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up the Tessie sensor platform from a config entry."""
|
||||
data = hass.data[DOMAIN][entry.entry_id]
|
||||
data = entry.runtime_data
|
||||
|
||||
async_add_entities(
|
||||
TessieSensorEntity(vehicle.state_coordinator, description)
|
||||
for vehicle in data
|
||||
TessieSensorEntity(vehicle, description)
|
||||
for vehicle in data.vehicles
|
||||
for description in DESCRIPTIONS
|
||||
)
|
||||
|
||||
|
|
|
@ -24,11 +24,10 @@ from homeassistant.components.switch import (
|
|||
SwitchEntity,
|
||||
SwitchEntityDescription,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import DOMAIN
|
||||
from . import TessieConfigEntry
|
||||
from .coordinator import TessieStateUpdateCoordinator
|
||||
from .entity import TessieEntity
|
||||
|
||||
|
@ -71,17 +70,19 @@ DESCRIPTIONS: tuple[TessieSwitchEntityDescription, ...] = (
|
|||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||
hass: HomeAssistant,
|
||||
entry: TessieConfigEntry,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up the Tessie Switch platform from a config entry."""
|
||||
data = hass.data[DOMAIN][entry.entry_id]
|
||||
data = entry.runtime_data
|
||||
|
||||
async_add_entities(
|
||||
[
|
||||
TessieSwitchEntity(vehicle.state_coordinator, description)
|
||||
for vehicle in data
|
||||
TessieSwitchEntity(vehicle, description)
|
||||
for vehicle in data.vehicles
|
||||
for description in DESCRIPTIONS
|
||||
if description.key in vehicle.state_coordinator.data
|
||||
if description.key in vehicle.data
|
||||
]
|
||||
)
|
||||
|
||||
|
|
|
@ -7,24 +7,24 @@ from typing import Any
|
|||
from tessie_api import schedule_software_update
|
||||
|
||||
from homeassistant.components.update import UpdateEntity, UpdateEntityFeature
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import DOMAIN, TessieUpdateStatus
|
||||
from . import TessieConfigEntry
|
||||
from .const import TessieUpdateStatus
|
||||
from .coordinator import TessieStateUpdateCoordinator
|
||||
from .entity import TessieEntity
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||
hass: HomeAssistant,
|
||||
entry: TessieConfigEntry,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up the Tessie Update platform from a config entry."""
|
||||
data = hass.data[DOMAIN][entry.entry_id]
|
||||
data = entry.runtime_data
|
||||
|
||||
async_add_entities(
|
||||
TessieUpdateEntity(vehicle.state_coordinator) for vehicle in data
|
||||
)
|
||||
async_add_entities(TessieUpdateEntity(vehicle) for vehicle in data.vehicles)
|
||||
|
||||
|
||||
class TessieUpdateEntity(TessieEntity, UpdateEntity):
|
||||
|
|
Loading…
Reference in New Issue