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