Update coordinator typing (6) [t-v] (#68466)

This commit is contained in:
Marc Mueller 2022-03-21 14:20:35 +01:00 committed by GitHub
parent 0d29b7cbb3
commit add741d789
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 39 additions and 70 deletions

View File

@ -94,11 +94,9 @@ async def async_setup_platform(
) )
class TautulliSensor(CoordinatorEntity, SensorEntity): class TautulliSensor(CoordinatorEntity[TautulliDataUpdateCoordinator], SensorEntity):
"""Representation of a Tautulli sensor.""" """Representation of a Tautulli sensor."""
coordinator: TautulliDataUpdateCoordinator
def __init__( def __init__(
self, self,
coordinator: TautulliDataUpdateCoordinator, coordinator: TautulliDataUpdateCoordinator,

View File

@ -92,11 +92,9 @@ class ToloSaunaUpdateCoordinator(DataUpdateCoordinator[ToloSaunaData]):
return ToloSaunaData(status, settings) return ToloSaunaData(status, settings)
class ToloSaunaCoordinatorEntity(CoordinatorEntity): class ToloSaunaCoordinatorEntity(CoordinatorEntity[ToloSaunaUpdateCoordinator]):
"""CoordinatorEntity for TOLO Sauna.""" """CoordinatorEntity for TOLO Sauna."""
coordinator: ToloSaunaUpdateCoordinator
def __init__( def __init__(
self, coordinator: ToloSaunaUpdateCoordinator, entry: ConfigEntry self, coordinator: ToloSaunaUpdateCoordinator, entry: ConfigEntry
) -> None: ) -> None:

View File

@ -316,7 +316,7 @@ class TomorrowioDataUpdateCoordinator(DataUpdateCoordinator):
raise UpdateFailed from error raise UpdateFailed from error
class TomorrowioEntity(CoordinatorEntity): class TomorrowioEntity(CoordinatorEntity[TomorrowioDataUpdateCoordinator]):
"""Base Tomorrow.io Entity.""" """Base Tomorrow.io Entity."""
def __init__( def __init__(

View File

@ -10,11 +10,9 @@ from .const import DOMAIN
from .coordinator import ToonDataUpdateCoordinator from .coordinator import ToonDataUpdateCoordinator
class ToonEntity(CoordinatorEntity): class ToonEntity(CoordinatorEntity[ToonDataUpdateCoordinator]):
"""Defines a base Toon entity.""" """Defines a base Toon entity."""
coordinator: ToonDataUpdateCoordinator
class ToonDisplayDeviceEntity(ToonEntity): class ToonDisplayDeviceEntity(ToonEntity):
"""Defines a Toon display device entity.""" """Defines a Toon display device entity."""

View File

@ -30,11 +30,9 @@ def async_refresh_after(
return _async_wrap return _async_wrap
class CoordinatedTPLinkEntity(CoordinatorEntity): class CoordinatedTPLinkEntity(CoordinatorEntity[TPLinkDataUpdateCoordinator]):
"""Common base class for all coordinated tplink entities.""" """Common base class for all coordinated tplink entities."""
coordinator: TPLinkDataUpdateCoordinator
def __init__( def __init__(
self, device: SmartDevice, coordinator: TPLinkDataUpdateCoordinator self, device: SmartDevice, coordinator: TPLinkDataUpdateCoordinator
) -> None: ) -> None:

View File

@ -49,7 +49,6 @@ async def async_setup_entry(
class TPLinkSmartBulb(CoordinatedTPLinkEntity, LightEntity): class TPLinkSmartBulb(CoordinatedTPLinkEntity, LightEntity):
"""Representation of a TPLink Smart Bulb.""" """Representation of a TPLink Smart Bulb."""
coordinator: TPLinkDataUpdateCoordinator
device: SmartBulb device: SmartBulb
def __init__( def __init__(

View File

@ -140,7 +140,6 @@ async def async_setup_entry(
class SmartPlugSensor(CoordinatedTPLinkEntity, SensorEntity): class SmartPlugSensor(CoordinatedTPLinkEntity, SensorEntity):
"""Representation of a TPLink Smart Plug energy sensor.""" """Representation of a TPLink Smart Plug energy sensor."""
coordinator: TPLinkDataUpdateCoordinator
entity_description: TPLinkSensorEntityDescription entity_description: TPLinkSensorEntityDescription
def __init__( def __init__(

View File

@ -47,7 +47,6 @@ async def async_setup_entry(
class SmartPlugLedSwitch(CoordinatedTPLinkEntity, SwitchEntity): class SmartPlugLedSwitch(CoordinatedTPLinkEntity, SwitchEntity):
"""Representation of switch for the LED of a TPLink Smart Plug.""" """Representation of switch for the LED of a TPLink Smart Plug."""
coordinator: TPLinkDataUpdateCoordinator
device: SmartPlug device: SmartPlug
_attr_entity_category = EntityCategory.CONFIG _attr_entity_category = EntityCategory.CONFIG
@ -85,8 +84,6 @@ class SmartPlugLedSwitch(CoordinatedTPLinkEntity, SwitchEntity):
class SmartPlugSwitch(CoordinatedTPLinkEntity, SwitchEntity): class SmartPlugSwitch(CoordinatedTPLinkEntity, SwitchEntity):
"""Representation of a TPLink Smart Plug switch.""" """Representation of a TPLink Smart Plug switch."""
coordinator: TPLinkDataUpdateCoordinator
def __init__( def __init__(
self, self,
device: SmartDevice, device: SmartDevice,

View File

@ -37,11 +37,9 @@ def handle_error(
return wrapper return wrapper
class TradfriBaseEntity(CoordinatorEntity): class TradfriBaseEntity(CoordinatorEntity[TradfriDeviceDataUpdateCoordinator]):
"""Base Tradfri device.""" """Base Tradfri device."""
coordinator: TradfriDeviceDataUpdateCoordinator
def __init__( def __init__(
self, self,
device_coordinator: TradfriDeviceDataUpdateCoordinator, device_coordinator: TradfriDeviceDataUpdateCoordinator,

View File

@ -78,7 +78,7 @@ async def async_setup_entry(
async_add_entities(entities) async_add_entities(entities)
class TradfriGroup(CoordinatorEntity, LightEntity): class TradfriGroup(CoordinatorEntity[TradfriGroupDataUpdateCoordinator], LightEntity):
"""The platform class for light groups required by hass.""" """The platform class for light groups required by hass."""
_attr_supported_features = SUPPORTED_GROUP_FEATURES _attr_supported_features = SUPPORTED_GROUP_FEATURES

View File

@ -174,7 +174,7 @@ async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) ->
return unload_ok return unload_ok
class UpCloudServerEntity(CoordinatorEntity): class UpCloudServerEntity(CoordinatorEntity[UpCloudDataUpdateCoordinator]):
"""Entity class for UpCloud servers.""" """Entity class for UpCloud servers."""
def __init__( def __init__(

View File

@ -235,10 +235,9 @@ class UpnpDataUpdateCoordinator(DataUpdateCoordinator):
} }
class UpnpEntity(CoordinatorEntity): class UpnpEntity(CoordinatorEntity[UpnpDataUpdateCoordinator]):
"""Base class for UPnP/IGD entities.""" """Base class for UPnP/IGD entities."""
coordinator: UpnpDataUpdateCoordinator
entity_description: UpnpSensorEntityDescription | UpnpBinarySensorEntityDescription entity_description: UpnpSensorEntityDescription | UpnpBinarySensorEntityDescription
def __init__( def __init__(

View File

@ -11,11 +11,10 @@ from . import UptimeRobotDataUpdateCoordinator
from .const import ATTR_TARGET, ATTRIBUTION, DOMAIN from .const import ATTR_TARGET, ATTRIBUTION, DOMAIN
class UptimeRobotEntity(CoordinatorEntity): class UptimeRobotEntity(CoordinatorEntity[UptimeRobotDataUpdateCoordinator]):
"""Base UptimeRobot entity.""" """Base UptimeRobot entity."""
_attr_attribution = ATTRIBUTION _attr_attribution = ATTRIBUTION
coordinator: UptimeRobotDataUpdateCoordinator
def __init__( def __init__(
self, self,

View File

@ -131,11 +131,9 @@ class ValloxState:
return next_filter_change_date return next_filter_change_date
class ValloxDataUpdateCoordinator(DataUpdateCoordinator): class ValloxDataUpdateCoordinator(DataUpdateCoordinator[ValloxState]):
"""The DataUpdateCoordinator for Vallox.""" """The DataUpdateCoordinator for Vallox."""
data: ValloxState
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the integration from configuration.yaml (DEPRECATED).""" """Set up the integration from configuration.yaml (DEPRECATED)."""

View File

@ -16,11 +16,12 @@ from . import ValloxDataUpdateCoordinator
from .const import DOMAIN from .const import DOMAIN
class ValloxBinarySensor(CoordinatorEntity, BinarySensorEntity): class ValloxBinarySensor(
CoordinatorEntity[ValloxDataUpdateCoordinator], BinarySensorEntity
):
"""Representation of a Vallox binary sensor.""" """Representation of a Vallox binary sensor."""
entity_description: ValloxBinarySensorEntityDescription entity_description: ValloxBinarySensorEntityDescription
coordinator: ValloxDataUpdateCoordinator
def __init__( def __init__(
self, self,

View File

@ -80,11 +80,9 @@ async def async_setup_entry(
async_add_entities([device]) async_add_entities([device])
class ValloxFan(CoordinatorEntity, FanEntity): class ValloxFan(CoordinatorEntity[ValloxDataUpdateCoordinator], FanEntity):
"""Representation of the fan.""" """Representation of the fan."""
coordinator: ValloxDataUpdateCoordinator
def __init__( def __init__(
self, self,
name: str, name: str,

View File

@ -32,11 +32,10 @@ from .const import (
) )
class ValloxSensor(CoordinatorEntity, SensorEntity): class ValloxSensor(CoordinatorEntity[ValloxDataUpdateCoordinator], SensorEntity):
"""Representation of a Vallox sensor.""" """Representation of a Vallox sensor."""
entity_description: ValloxSensorEntityDescription entity_description: ValloxSensorEntityDescription
coordinator: ValloxDataUpdateCoordinator
def __init__( def __init__(
self, self,

View File

@ -126,11 +126,9 @@ class VenstarDataUpdateCoordinator(update_coordinator.DataUpdateCoordinator):
return None return None
class VenstarEntity(CoordinatorEntity): class VenstarEntity(CoordinatorEntity[VenstarDataUpdateCoordinator]):
"""Representation of a Venstar entity.""" """Representation of a Venstar entity."""
coordinator: VenstarDataUpdateCoordinator
def __init__( def __init__(
self, self,
venstar_data_coordinator: VenstarDataUpdateCoordinator, venstar_data_coordinator: VenstarDataUpdateCoordinator,

View File

@ -30,11 +30,11 @@ async def async_setup_entry(
async_add_entities([VerisureAlarm(coordinator=hass.data[DOMAIN][entry.entry_id])]) async_add_entities([VerisureAlarm(coordinator=hass.data[DOMAIN][entry.entry_id])])
class VerisureAlarm(CoordinatorEntity, AlarmControlPanelEntity): class VerisureAlarm(
CoordinatorEntity[VerisureDataUpdateCoordinator], AlarmControlPanelEntity
):
"""Representation of a Verisure alarm status.""" """Representation of a Verisure alarm status."""
coordinator: VerisureDataUpdateCoordinator
_attr_code_format = FORMAT_NUMBER _attr_code_format = FORMAT_NUMBER
_attr_name = "Verisure Alarm" _attr_name = "Verisure Alarm"
_attr_supported_features = SUPPORT_ALARM_ARM_HOME | SUPPORT_ALARM_ARM_AWAY _attr_supported_features = SUPPORT_ALARM_ARM_HOME | SUPPORT_ALARM_ARM_AWAY

View File

@ -33,11 +33,11 @@ async def async_setup_entry(
async_add_entities(sensors) async_add_entities(sensors)
class VerisureDoorWindowSensor(CoordinatorEntity, BinarySensorEntity): class VerisureDoorWindowSensor(
CoordinatorEntity[VerisureDataUpdateCoordinator], BinarySensorEntity
):
"""Representation of a Verisure door window sensor.""" """Representation of a Verisure door window sensor."""
coordinator: VerisureDataUpdateCoordinator
_attr_device_class = BinarySensorDeviceClass.OPENING _attr_device_class = BinarySensorDeviceClass.OPENING
def __init__( def __init__(
@ -79,11 +79,11 @@ class VerisureDoorWindowSensor(CoordinatorEntity, BinarySensorEntity):
) )
class VerisureEthernetStatus(CoordinatorEntity, BinarySensorEntity): class VerisureEthernetStatus(
CoordinatorEntity[VerisureDataUpdateCoordinator], BinarySensorEntity
):
"""Representation of a Verisure VBOX internet status.""" """Representation of a Verisure VBOX internet status."""
coordinator: VerisureDataUpdateCoordinator
_attr_name = "Verisure Ethernet status" _attr_name = "Verisure Ethernet status"
_attr_device_class = BinarySensorDeviceClass.CONNECTIVITY _attr_device_class = BinarySensorDeviceClass.CONNECTIVITY
_attr_entity_category = EntityCategory.DIAGNOSTIC _attr_entity_category = EntityCategory.DIAGNOSTIC

View File

@ -43,11 +43,9 @@ async def async_setup_entry(
) )
class VerisureSmartcam(CoordinatorEntity, Camera): class VerisureSmartcam(CoordinatorEntity[VerisureDataUpdateCoordinator], Camera):
"""Representation of a Verisure camera.""" """Representation of a Verisure camera."""
coordinator: VerisureDataUpdateCoordinator
def __init__( def __init__(
self, self,
coordinator: VerisureDataUpdateCoordinator, coordinator: VerisureDataUpdateCoordinator,

View File

@ -55,11 +55,9 @@ async def async_setup_entry(
) )
class VerisureDoorlock(CoordinatorEntity, LockEntity): class VerisureDoorlock(CoordinatorEntity[VerisureDataUpdateCoordinator], LockEntity):
"""Representation of a Verisure doorlock.""" """Representation of a Verisure doorlock."""
coordinator: VerisureDataUpdateCoordinator
def __init__( def __init__(
self, coordinator: VerisureDataUpdateCoordinator, serial_number: str self, coordinator: VerisureDataUpdateCoordinator, serial_number: str
) -> None: ) -> None:

View File

@ -45,11 +45,11 @@ async def async_setup_entry(
async_add_entities(sensors) async_add_entities(sensors)
class VerisureThermometer(CoordinatorEntity, SensorEntity): class VerisureThermometer(
CoordinatorEntity[VerisureDataUpdateCoordinator], SensorEntity
):
"""Representation of a Verisure thermometer.""" """Representation of a Verisure thermometer."""
coordinator: VerisureDataUpdateCoordinator
_attr_device_class = SensorDeviceClass.TEMPERATURE _attr_device_class = SensorDeviceClass.TEMPERATURE
_attr_native_unit_of_measurement = TEMP_CELSIUS _attr_native_unit_of_measurement = TEMP_CELSIUS
_attr_state_class = SensorStateClass.MEASUREMENT _attr_state_class = SensorStateClass.MEASUREMENT
@ -100,11 +100,11 @@ class VerisureThermometer(CoordinatorEntity, SensorEntity):
) )
class VerisureHygrometer(CoordinatorEntity, SensorEntity): class VerisureHygrometer(
CoordinatorEntity[VerisureDataUpdateCoordinator], SensorEntity
):
"""Representation of a Verisure hygrometer.""" """Representation of a Verisure hygrometer."""
coordinator: VerisureDataUpdateCoordinator
_attr_device_class = SensorDeviceClass.HUMIDITY _attr_device_class = SensorDeviceClass.HUMIDITY
_attr_native_unit_of_measurement = PERCENTAGE _attr_native_unit_of_measurement = PERCENTAGE
_attr_state_class = SensorStateClass.MEASUREMENT _attr_state_class = SensorStateClass.MEASUREMENT
@ -155,11 +155,11 @@ class VerisureHygrometer(CoordinatorEntity, SensorEntity):
) )
class VerisureMouseDetection(CoordinatorEntity, SensorEntity): class VerisureMouseDetection(
CoordinatorEntity[VerisureDataUpdateCoordinator], SensorEntity
):
"""Representation of a Verisure mouse detector.""" """Representation of a Verisure mouse detector."""
coordinator: VerisureDataUpdateCoordinator
_attr_native_unit_of_measurement = "Mice" _attr_native_unit_of_measurement = "Mice"
def __init__( def __init__(

View File

@ -27,11 +27,9 @@ async def async_setup_entry(
) )
class VerisureSmartplug(CoordinatorEntity, SwitchEntity): class VerisureSmartplug(CoordinatorEntity[VerisureDataUpdateCoordinator], SwitchEntity):
"""Representation of a Verisure smartplug.""" """Representation of a Verisure smartplug."""
coordinator: VerisureDataUpdateCoordinator
def __init__( def __init__(
self, coordinator: VerisureDataUpdateCoordinator, serial_number: str self, coordinator: VerisureDataUpdateCoordinator, serial_number: str
) -> None: ) -> None:

View File

@ -8,7 +8,7 @@ from .const import DOMAIN, HOME_ASSISTANT
from .coordinator import VersionDataUpdateCoordinator from .coordinator import VersionDataUpdateCoordinator
class VersionEntity(CoordinatorEntity): class VersionEntity(CoordinatorEntity[VersionDataUpdateCoordinator]):
"""Common entity class for Version integration.""" """Common entity class for Version integration."""
_attr_device_info = DeviceInfo( _attr_device_info = DeviceInfo(
@ -18,8 +18,6 @@ class VersionEntity(CoordinatorEntity):
entry_type=DeviceEntryType.SERVICE, entry_type=DeviceEntryType.SERVICE,
) )
coordinator: VersionDataUpdateCoordinator
def __init__( def __init__(
self, self,
coordinator: VersionDataUpdateCoordinator, coordinator: VersionDataUpdateCoordinator,