Update coordinator typing (7) [w-z] (#68467)
parent
539a469a8b
commit
129c9e42f1
|
@ -148,11 +148,9 @@ class InvalidAuth(HomeAssistantError):
|
|||
"""Error to indicate there is invalid auth."""
|
||||
|
||||
|
||||
class WallboxEntity(CoordinatorEntity):
|
||||
class WallboxEntity(CoordinatorEntity[WallboxCoordinator]):
|
||||
"""Defines a base Wallbox entity."""
|
||||
|
||||
coordinator: WallboxCoordinator
|
||||
|
||||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device information about this Wallbox device."""
|
||||
|
|
|
@ -59,7 +59,6 @@ class WallboxNumber(WallboxEntity, NumberEntity):
|
|||
"""Representation of the Wallbox portal."""
|
||||
|
||||
entity_description: WallboxNumberEntityDescription
|
||||
coordinator: WallboxCoordinator
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
|
|
|
@ -152,7 +152,6 @@ class WallboxSensor(WallboxEntity, SensorEntity):
|
|||
"""Representation of the Wallbox portal."""
|
||||
|
||||
entity_description: WallboxSensorEntityDescription
|
||||
coordinator: WallboxCoordinator
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
|
|
|
@ -16,11 +16,9 @@ from .wemo_device import DeviceCoordinator
|
|||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class WemoEntity(CoordinatorEntity):
|
||||
class WemoEntity(CoordinatorEntity[DeviceCoordinator]):
|
||||
"""Common methods for Wemo entities."""
|
||||
|
||||
coordinator: DeviceCoordinator # Override CoordinatorEntity.coordinator type.
|
||||
|
||||
# Most pyWeMo devices are associated with a single Home Assistant entity. When
|
||||
# that is not the case, name_suffix & unique_id_suffix can be used to provide
|
||||
# names and unique ids for additional Home Assistant entities.
|
||||
|
|
|
@ -7,11 +7,9 @@ from .const import DOMAIN
|
|||
from .coordinator import WLEDDataUpdateCoordinator
|
||||
|
||||
|
||||
class WLEDEntity(CoordinatorEntity):
|
||||
class WLEDEntity(CoordinatorEntity[WLEDDataUpdateCoordinator]):
|
||||
"""Defines a base WLED entity."""
|
||||
|
||||
coordinator: WLEDDataUpdateCoordinator
|
||||
|
||||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device information about this WLED device."""
|
||||
|
|
|
@ -11,7 +11,7 @@ from . import PresenceData, XboxUpdateCoordinator
|
|||
from .const import DOMAIN
|
||||
|
||||
|
||||
class XboxBaseSensorEntity(CoordinatorEntity):
|
||||
class XboxBaseSensorEntity(CoordinatorEntity[XboxUpdateCoordinator]):
|
||||
"""Base Sensor for the Xbox Integration."""
|
||||
|
||||
def __init__(
|
||||
|
|
|
@ -78,7 +78,7 @@ async def async_setup_entry(
|
|||
)
|
||||
|
||||
|
||||
class XboxMediaPlayer(CoordinatorEntity, MediaPlayerEntity):
|
||||
class XboxMediaPlayer(CoordinatorEntity[XboxUpdateCoordinator], MediaPlayerEntity):
|
||||
"""Representation of an Xbox Media Player."""
|
||||
|
||||
def __init__(
|
||||
|
|
|
@ -45,7 +45,7 @@ async def async_setup_entry(
|
|||
)
|
||||
|
||||
|
||||
class XboxRemote(CoordinatorEntity, RemoteEntity):
|
||||
class XboxRemote(CoordinatorEntity[XboxUpdateCoordinator], RemoteEntity):
|
||||
"""Representation of an Xbox remote."""
|
||||
|
||||
def __init__(
|
||||
|
|
|
@ -3,6 +3,7 @@ import datetime
|
|||
from enum import Enum
|
||||
from functools import partial
|
||||
import logging
|
||||
from typing import Any, TypeVar
|
||||
|
||||
from construct.core import ChecksumError
|
||||
from miio import Device, DeviceException
|
||||
|
@ -10,12 +11,17 @@ from miio import Device, DeviceException
|
|||
from homeassistant.const import ATTR_CONNECTIONS
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
from homeassistant.helpers.entity import DeviceInfo, Entity
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
from homeassistant.helpers.update_coordinator import (
|
||||
CoordinatorEntity,
|
||||
DataUpdateCoordinator,
|
||||
)
|
||||
|
||||
from .const import CONF_MAC, CONF_MODEL, DOMAIN, AuthException, SetupException
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
_T = TypeVar("_T", bound=DataUpdateCoordinator[Any])
|
||||
|
||||
|
||||
class ConnectXiaomiDevice:
|
||||
"""Class to async connect to a Xiaomi Device."""
|
||||
|
@ -101,7 +107,7 @@ class XiaomiMiioEntity(Entity):
|
|||
return device_info
|
||||
|
||||
|
||||
class XiaomiCoordinatedMiioEntity(CoordinatorEntity):
|
||||
class XiaomiCoordinatedMiioEntity(CoordinatorEntity[_T]):
|
||||
"""Representation of a base a coordinated Xiaomi Miio Entity."""
|
||||
|
||||
def __init__(self, name, device, entry, unique_id, coordinator):
|
||||
|
|
|
@ -203,13 +203,19 @@ async def async_setup_entry(
|
|||
async_add_entities(entities, update_before_add=True)
|
||||
|
||||
|
||||
class MiroboVacuum(XiaomiCoordinatedMiioEntity, StateVacuumEntity):
|
||||
class MiroboVacuum(
|
||||
XiaomiCoordinatedMiioEntity[DataUpdateCoordinator[VacuumCoordinatorData]],
|
||||
StateVacuumEntity,
|
||||
):
|
||||
"""Representation of a Xiaomi Vacuum cleaner robot."""
|
||||
|
||||
coordinator: DataUpdateCoordinator[VacuumCoordinatorData]
|
||||
|
||||
def __init__(
|
||||
self, name, device, entry, unique_id, coordinator: DataUpdateCoordinator
|
||||
self,
|
||||
name,
|
||||
device,
|
||||
entry,
|
||||
unique_id,
|
||||
coordinator: DataUpdateCoordinator[VacuumCoordinatorData],
|
||||
):
|
||||
"""Initialize the Xiaomi vacuum cleaner robot handler."""
|
||||
super().__init__(name, device, entry, unique_id, coordinator)
|
||||
|
|
|
@ -81,8 +81,6 @@ async def async_setup_entry(
|
|||
class YaleAlarmDevice(YaleAlarmEntity, AlarmControlPanelEntity):
|
||||
"""Represent a Yale Smart Alarm."""
|
||||
|
||||
coordinator: YaleDataUpdateCoordinator
|
||||
|
||||
_attr_code_arm_required = False
|
||||
_attr_supported_features = SUPPORT_ALARM_ARM_HOME | SUPPORT_ALARM_ARM_AWAY
|
||||
|
||||
|
|
|
@ -9,11 +9,9 @@ from .const import DOMAIN, MANUFACTURER, MODEL
|
|||
from .coordinator import YaleDataUpdateCoordinator
|
||||
|
||||
|
||||
class YaleEntity(CoordinatorEntity, Entity):
|
||||
class YaleEntity(CoordinatorEntity[YaleDataUpdateCoordinator], Entity):
|
||||
"""Base implementation for Yale device."""
|
||||
|
||||
coordinator: YaleDataUpdateCoordinator
|
||||
|
||||
def __init__(self, coordinator: YaleDataUpdateCoordinator, data: dict) -> None:
|
||||
"""Initialize an Yale device."""
|
||||
super().__init__(coordinator)
|
||||
|
@ -28,11 +26,9 @@ class YaleEntity(CoordinatorEntity, Entity):
|
|||
)
|
||||
|
||||
|
||||
class YaleAlarmEntity(CoordinatorEntity, Entity):
|
||||
class YaleAlarmEntity(CoordinatorEntity[YaleDataUpdateCoordinator], Entity):
|
||||
"""Base implementation for Yale Alarm device."""
|
||||
|
||||
coordinator: YaleDataUpdateCoordinator
|
||||
|
||||
def __init__(self, coordinator: YaleDataUpdateCoordinator) -> None:
|
||||
"""Initialize an Yale device."""
|
||||
super().__init__(coordinator)
|
||||
|
|
|
@ -120,11 +120,9 @@ class MusicCastDataUpdateCoordinator(DataUpdateCoordinator[MusicCastData]):
|
|||
return self.musiccast.data
|
||||
|
||||
|
||||
class MusicCastEntity(CoordinatorEntity):
|
||||
class MusicCastEntity(CoordinatorEntity[MusicCastDataUpdateCoordinator]):
|
||||
"""Defines a base MusicCast entity."""
|
||||
|
||||
coordinator: MusicCastDataUpdateCoordinator
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
|
|
Loading…
Reference in New Issue