Update coordinator typing (2) [e-f] (#68462)
parent
073fb40b79
commit
354fc4c1ae
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
|||
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
from typing import Union
|
||||
|
||||
from pyeight.eight import EightSleep
|
||||
from pyeight.user import EightUser
|
||||
|
@ -227,7 +228,11 @@ class EightSleepUserDataCoordinator(DataUpdateCoordinator):
|
|||
await self.api.update_user_data()
|
||||
|
||||
|
||||
class EightSleepBaseEntity(CoordinatorEntity):
|
||||
class EightSleepBaseEntity(
|
||||
CoordinatorEntity[
|
||||
Union[EightSleepUserDataCoordinator, EightSleepHeatDataCoordinator]
|
||||
]
|
||||
):
|
||||
"""The base Eight Sleep entity class."""
|
||||
|
||||
def __init__(
|
||||
|
|
|
@ -61,14 +61,14 @@ async def async_setup_entry(
|
|||
)
|
||||
|
||||
|
||||
class ElgatoLight(ElgatoEntity, CoordinatorEntity, LightEntity):
|
||||
class ElgatoLight(
|
||||
ElgatoEntity, CoordinatorEntity[DataUpdateCoordinator[State]], LightEntity
|
||||
):
|
||||
"""Defines an Elgato Light."""
|
||||
|
||||
coordinator: DataUpdateCoordinator[State]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
coordinator: DataUpdateCoordinator,
|
||||
coordinator: DataUpdateCoordinator[State],
|
||||
client: Elgato,
|
||||
info: Info,
|
||||
mac: str | None,
|
||||
|
|
|
@ -116,11 +116,9 @@ class ElmaxCoordinator(DataUpdateCoordinator[PanelStatus]):
|
|||
) from err
|
||||
|
||||
|
||||
class ElmaxEntity(CoordinatorEntity):
|
||||
class ElmaxEntity(CoordinatorEntity[ElmaxCoordinator]):
|
||||
"""Wrapper for Elmax entities."""
|
||||
|
||||
coordinator: ElmaxCoordinator
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
panel: PanelEntry,
|
||||
|
|
|
@ -11,12 +11,12 @@ import pyevilgenius
|
|||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import (
|
||||
aiohttp_client,
|
||||
device_registry as dr,
|
||||
update_coordinator,
|
||||
)
|
||||
from homeassistant.helpers import aiohttp_client, device_registry as dr
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.update_coordinator import (
|
||||
CoordinatorEntity,
|
||||
DataUpdateCoordinator,
|
||||
)
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
|
@ -49,7 +49,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
return unload_ok
|
||||
|
||||
|
||||
class EvilGeniusUpdateCoordinator(update_coordinator.DataUpdateCoordinator[dict]):
|
||||
class EvilGeniusUpdateCoordinator(DataUpdateCoordinator[dict]):
|
||||
"""Update coordinator for Evil Genius data."""
|
||||
|
||||
info: dict
|
||||
|
@ -81,11 +81,9 @@ class EvilGeniusUpdateCoordinator(update_coordinator.DataUpdateCoordinator[dict]
|
|||
return cast(dict, await self.client.get_data())
|
||||
|
||||
|
||||
class EvilGeniusEntity(update_coordinator.CoordinatorEntity):
|
||||
class EvilGeniusEntity(CoordinatorEntity[EvilGeniusUpdateCoordinator]):
|
||||
"""Base entity for Evil Genius."""
|
||||
|
||||
coordinator: EvilGeniusUpdateCoordinator
|
||||
|
||||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device info."""
|
||||
|
|
|
@ -54,8 +54,6 @@ async def async_setup_entry(
|
|||
class EzvizBinarySensor(EzvizEntity, BinarySensorEntity):
|
||||
"""Representation of a Ezviz sensor."""
|
||||
|
||||
coordinator: EzvizDataUpdateCoordinator
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
coordinator: EzvizDataUpdateCoordinator,
|
||||
|
|
|
@ -228,8 +228,6 @@ async def async_setup_entry(
|
|||
class EzvizCamera(EzvizEntity, Camera):
|
||||
"""An implementation of a Ezviz security camera."""
|
||||
|
||||
coordinator: EzvizDataUpdateCoordinator
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
hass: HomeAssistant,
|
||||
|
|
|
@ -10,7 +10,7 @@ from .const import DOMAIN, MANUFACTURER
|
|||
from .coordinator import EzvizDataUpdateCoordinator
|
||||
|
||||
|
||||
class EzvizEntity(CoordinatorEntity, Entity):
|
||||
class EzvizEntity(CoordinatorEntity[EzvizDataUpdateCoordinator], Entity):
|
||||
"""Generic entity encapsulating common features of Ezviz device."""
|
||||
|
||||
def __init__(
|
||||
|
|
|
@ -39,7 +39,6 @@ async def async_setup_entry(
|
|||
class EzvizSwitch(EzvizEntity, SwitchEntity):
|
||||
"""Representation of a Ezviz sensor."""
|
||||
|
||||
coordinator: EzvizDataUpdateCoordinator
|
||||
_attr_device_class = SwitchDeviceClass.SWITCH
|
||||
|
||||
def __init__(
|
||||
|
|
|
@ -128,10 +128,9 @@ class FiveMEntityDescription(EntityDescription):
|
|||
extra_attrs: list[str] | None = None
|
||||
|
||||
|
||||
class FiveMEntity(CoordinatorEntity):
|
||||
class FiveMEntity(CoordinatorEntity[FiveMDataUpdateCoordinator]):
|
||||
"""Representation of a FiveM base entity."""
|
||||
|
||||
coordinator: FiveMDataUpdateCoordinator
|
||||
entity_description: FiveMEntityDescription
|
||||
|
||||
def __init__(
|
||||
|
|
|
@ -66,11 +66,9 @@ class FluxBaseEntity(Entity):
|
|||
self._attr_device_info = _async_device_info(self._device, entry)
|
||||
|
||||
|
||||
class FluxEntity(CoordinatorEntity):
|
||||
class FluxEntity(CoordinatorEntity[FluxLedUpdateCoordinator]):
|
||||
"""Representation of a Flux entity with a coordinator."""
|
||||
|
||||
coordinator: FluxLedUpdateCoordinator
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
coordinator: FluxLedUpdateCoordinator,
|
||||
|
|
|
@ -187,7 +187,9 @@ async def async_setup_entry(
|
|||
)
|
||||
|
||||
|
||||
class FluxLight(FluxOnOffEntity, CoordinatorEntity, LightEntity):
|
||||
class FluxLight(
|
||||
FluxOnOffEntity, CoordinatorEntity[FluxLedUpdateCoordinator], LightEntity
|
||||
):
|
||||
"""Representation of a Flux light."""
|
||||
|
||||
_attr_supported_features = SUPPORT_TRANSITION | SUPPORT_EFFECT
|
||||
|
|
|
@ -92,7 +92,9 @@ async def async_setup_entry(
|
|||
async_add_entities(entities)
|
||||
|
||||
|
||||
class FluxSpeedNumber(FluxEntity, CoordinatorEntity, NumberEntity):
|
||||
class FluxSpeedNumber(
|
||||
FluxEntity, CoordinatorEntity[FluxLedUpdateCoordinator], NumberEntity
|
||||
):
|
||||
"""Defines a flux_led speed number."""
|
||||
|
||||
_attr_min_value = 1
|
||||
|
@ -122,7 +124,9 @@ class FluxSpeedNumber(FluxEntity, CoordinatorEntity, NumberEntity):
|
|||
await self.coordinator.async_request_refresh()
|
||||
|
||||
|
||||
class FluxConfigNumber(FluxEntity, CoordinatorEntity, NumberEntity):
|
||||
class FluxConfigNumber(
|
||||
FluxEntity, CoordinatorEntity[FluxLedUpdateCoordinator], NumberEntity
|
||||
):
|
||||
"""Base class for flux config numbers."""
|
||||
|
||||
_attr_entity_category = EntityCategory.CONFIG
|
||||
|
|
|
@ -52,7 +52,9 @@ async def async_setup_entry(
|
|||
async_add_entities(entities)
|
||||
|
||||
|
||||
class FluxSwitch(FluxOnOffEntity, CoordinatorEntity, SwitchEntity):
|
||||
class FluxSwitch(
|
||||
FluxOnOffEntity, CoordinatorEntity[FluxLedUpdateCoordinator], SwitchEntity
|
||||
):
|
||||
"""Representation of a Flux switch."""
|
||||
|
||||
async def _async_turn_on(self, **kwargs: Any) -> None:
|
||||
|
|
|
@ -817,7 +817,7 @@ class FritzData:
|
|||
profile_switches: dict = field(default_factory=dict)
|
||||
|
||||
|
||||
class FritzDeviceBase(update_coordinator.CoordinatorEntity):
|
||||
class FritzDeviceBase(update_coordinator.CoordinatorEntity[AvmWrapper]):
|
||||
"""Entity base class for a device connected to a FRITZ!Box device."""
|
||||
|
||||
def __init__(self, avm_wrapper: AvmWrapper, device: FritzDevice) -> None:
|
||||
|
|
|
@ -93,11 +93,9 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
return unload_ok
|
||||
|
||||
|
||||
class FritzBoxEntity(CoordinatorEntity):
|
||||
class FritzBoxEntity(CoordinatorEntity[FritzboxDataUpdateCoordinator]):
|
||||
"""Basis FritzBox entity."""
|
||||
|
||||
coordinator: FritzboxDataUpdateCoordinator
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
coordinator: FritzboxDataUpdateCoordinator,
|
||||
|
|
|
@ -691,10 +691,9 @@ STORAGE_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [
|
|||
]
|
||||
|
||||
|
||||
class _FroniusSensorEntity(CoordinatorEntity, SensorEntity):
|
||||
class _FroniusSensorEntity(CoordinatorEntity["FroniusCoordinatorBase"], SensorEntity):
|
||||
"""Defines a Fronius coordinator entity."""
|
||||
|
||||
coordinator: FroniusCoordinatorBase
|
||||
entity_descriptions: list[SensorEntityDescription]
|
||||
_entity_id_prefix: str
|
||||
|
||||
|
|
Loading…
Reference in New Issue