From add741d7896c282411b88e62d994ff6dbc1ee13f Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Mon, 21 Mar 2022 14:20:35 +0100 Subject: [PATCH] Update coordinator typing (6) [t-v] (#68466) --- homeassistant/components/tautulli/sensor.py | 4 +--- homeassistant/components/tolo/__init__.py | 4 +--- .../components/tomorrowio/__init__.py | 2 +- homeassistant/components/toon/models.py | 4 +--- homeassistant/components/tplink/entity.py | 4 +--- homeassistant/components/tplink/light.py | 1 - homeassistant/components/tplink/sensor.py | 1 - homeassistant/components/tplink/switch.py | 3 --- homeassistant/components/tradfri/base_class.py | 4 +--- homeassistant/components/tradfri/light.py | 2 +- homeassistant/components/upcloud/__init__.py | 2 +- homeassistant/components/upnp/__init__.py | 3 +-- homeassistant/components/uptimerobot/entity.py | 3 +-- homeassistant/components/vallox/__init__.py | 4 +--- .../components/vallox/binary_sensor.py | 5 +++-- homeassistant/components/vallox/fan.py | 4 +--- homeassistant/components/vallox/sensor.py | 3 +-- homeassistant/components/venstar/__init__.py | 4 +--- .../components/verisure/alarm_control_panel.py | 6 +++--- .../components/verisure/binary_sensor.py | 12 ++++++------ homeassistant/components/verisure/camera.py | 4 +--- homeassistant/components/verisure/lock.py | 4 +--- homeassistant/components/verisure/sensor.py | 18 +++++++++--------- homeassistant/components/verisure/switch.py | 4 +--- homeassistant/components/version/entity.py | 4 +--- 25 files changed, 39 insertions(+), 70 deletions(-) diff --git a/homeassistant/components/tautulli/sensor.py b/homeassistant/components/tautulli/sensor.py index 814f6c9da50..f28e334e1c0 100644 --- a/homeassistant/components/tautulli/sensor.py +++ b/homeassistant/components/tautulli/sensor.py @@ -94,11 +94,9 @@ async def async_setup_platform( ) -class TautulliSensor(CoordinatorEntity, SensorEntity): +class TautulliSensor(CoordinatorEntity[TautulliDataUpdateCoordinator], SensorEntity): """Representation of a Tautulli sensor.""" - coordinator: TautulliDataUpdateCoordinator - def __init__( self, coordinator: TautulliDataUpdateCoordinator, diff --git a/homeassistant/components/tolo/__init__.py b/homeassistant/components/tolo/__init__.py index 6f17379dfbf..3b78adacbac 100644 --- a/homeassistant/components/tolo/__init__.py +++ b/homeassistant/components/tolo/__init__.py @@ -92,11 +92,9 @@ class ToloSaunaUpdateCoordinator(DataUpdateCoordinator[ToloSaunaData]): return ToloSaunaData(status, settings) -class ToloSaunaCoordinatorEntity(CoordinatorEntity): +class ToloSaunaCoordinatorEntity(CoordinatorEntity[ToloSaunaUpdateCoordinator]): """CoordinatorEntity for TOLO Sauna.""" - coordinator: ToloSaunaUpdateCoordinator - def __init__( self, coordinator: ToloSaunaUpdateCoordinator, entry: ConfigEntry ) -> None: diff --git a/homeassistant/components/tomorrowio/__init__.py b/homeassistant/components/tomorrowio/__init__.py index a46f9a9222e..68070164312 100644 --- a/homeassistant/components/tomorrowio/__init__.py +++ b/homeassistant/components/tomorrowio/__init__.py @@ -316,7 +316,7 @@ class TomorrowioDataUpdateCoordinator(DataUpdateCoordinator): raise UpdateFailed from error -class TomorrowioEntity(CoordinatorEntity): +class TomorrowioEntity(CoordinatorEntity[TomorrowioDataUpdateCoordinator]): """Base Tomorrow.io Entity.""" def __init__( diff --git a/homeassistant/components/toon/models.py b/homeassistant/components/toon/models.py index 57db44beb6b..e39faa1efc6 100644 --- a/homeassistant/components/toon/models.py +++ b/homeassistant/components/toon/models.py @@ -10,11 +10,9 @@ from .const import DOMAIN from .coordinator import ToonDataUpdateCoordinator -class ToonEntity(CoordinatorEntity): +class ToonEntity(CoordinatorEntity[ToonDataUpdateCoordinator]): """Defines a base Toon entity.""" - coordinator: ToonDataUpdateCoordinator - class ToonDisplayDeviceEntity(ToonEntity): """Defines a Toon display device entity.""" diff --git a/homeassistant/components/tplink/entity.py b/homeassistant/components/tplink/entity.py index 4380b1397b6..173d1d7930f 100644 --- a/homeassistant/components/tplink/entity.py +++ b/homeassistant/components/tplink/entity.py @@ -30,11 +30,9 @@ def async_refresh_after( return _async_wrap -class CoordinatedTPLinkEntity(CoordinatorEntity): +class CoordinatedTPLinkEntity(CoordinatorEntity[TPLinkDataUpdateCoordinator]): """Common base class for all coordinated tplink entities.""" - coordinator: TPLinkDataUpdateCoordinator - def __init__( self, device: SmartDevice, coordinator: TPLinkDataUpdateCoordinator ) -> None: diff --git a/homeassistant/components/tplink/light.py b/homeassistant/components/tplink/light.py index 6efabe537f7..30d7fbde40a 100644 --- a/homeassistant/components/tplink/light.py +++ b/homeassistant/components/tplink/light.py @@ -49,7 +49,6 @@ async def async_setup_entry( class TPLinkSmartBulb(CoordinatedTPLinkEntity, LightEntity): """Representation of a TPLink Smart Bulb.""" - coordinator: TPLinkDataUpdateCoordinator device: SmartBulb def __init__( diff --git a/homeassistant/components/tplink/sensor.py b/homeassistant/components/tplink/sensor.py index fe9cb699114..7ba28702114 100644 --- a/homeassistant/components/tplink/sensor.py +++ b/homeassistant/components/tplink/sensor.py @@ -140,7 +140,6 @@ async def async_setup_entry( class SmartPlugSensor(CoordinatedTPLinkEntity, SensorEntity): """Representation of a TPLink Smart Plug energy sensor.""" - coordinator: TPLinkDataUpdateCoordinator entity_description: TPLinkSensorEntityDescription def __init__( diff --git a/homeassistant/components/tplink/switch.py b/homeassistant/components/tplink/switch.py index 451ec6d5f8b..2b53c67d296 100644 --- a/homeassistant/components/tplink/switch.py +++ b/homeassistant/components/tplink/switch.py @@ -47,7 +47,6 @@ async def async_setup_entry( class SmartPlugLedSwitch(CoordinatedTPLinkEntity, SwitchEntity): """Representation of switch for the LED of a TPLink Smart Plug.""" - coordinator: TPLinkDataUpdateCoordinator device: SmartPlug _attr_entity_category = EntityCategory.CONFIG @@ -85,8 +84,6 @@ class SmartPlugLedSwitch(CoordinatedTPLinkEntity, SwitchEntity): class SmartPlugSwitch(CoordinatedTPLinkEntity, SwitchEntity): """Representation of a TPLink Smart Plug switch.""" - coordinator: TPLinkDataUpdateCoordinator - def __init__( self, device: SmartDevice, diff --git a/homeassistant/components/tradfri/base_class.py b/homeassistant/components/tradfri/base_class.py index a2bd28e3868..727e611dca4 100644 --- a/homeassistant/components/tradfri/base_class.py +++ b/homeassistant/components/tradfri/base_class.py @@ -37,11 +37,9 @@ def handle_error( return wrapper -class TradfriBaseEntity(CoordinatorEntity): +class TradfriBaseEntity(CoordinatorEntity[TradfriDeviceDataUpdateCoordinator]): """Base Tradfri device.""" - coordinator: TradfriDeviceDataUpdateCoordinator - def __init__( self, device_coordinator: TradfriDeviceDataUpdateCoordinator, diff --git a/homeassistant/components/tradfri/light.py b/homeassistant/components/tradfri/light.py index 9b6ad3e9f06..bae626017e7 100644 --- a/homeassistant/components/tradfri/light.py +++ b/homeassistant/components/tradfri/light.py @@ -78,7 +78,7 @@ async def async_setup_entry( async_add_entities(entities) -class TradfriGroup(CoordinatorEntity, LightEntity): +class TradfriGroup(CoordinatorEntity[TradfriGroupDataUpdateCoordinator], LightEntity): """The platform class for light groups required by hass.""" _attr_supported_features = SUPPORTED_GROUP_FEATURES diff --git a/homeassistant/components/upcloud/__init__.py b/homeassistant/components/upcloud/__init__.py index a824bc596d0..e42659948d8 100644 --- a/homeassistant/components/upcloud/__init__.py +++ b/homeassistant/components/upcloud/__init__.py @@ -174,7 +174,7 @@ async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> return unload_ok -class UpCloudServerEntity(CoordinatorEntity): +class UpCloudServerEntity(CoordinatorEntity[UpCloudDataUpdateCoordinator]): """Entity class for UpCloud servers.""" def __init__( diff --git a/homeassistant/components/upnp/__init__.py b/homeassistant/components/upnp/__init__.py index c7988fe98c9..e15c90c7079 100644 --- a/homeassistant/components/upnp/__init__.py +++ b/homeassistant/components/upnp/__init__.py @@ -235,10 +235,9 @@ class UpnpDataUpdateCoordinator(DataUpdateCoordinator): } -class UpnpEntity(CoordinatorEntity): +class UpnpEntity(CoordinatorEntity[UpnpDataUpdateCoordinator]): """Base class for UPnP/IGD entities.""" - coordinator: UpnpDataUpdateCoordinator entity_description: UpnpSensorEntityDescription | UpnpBinarySensorEntityDescription def __init__( diff --git a/homeassistant/components/uptimerobot/entity.py b/homeassistant/components/uptimerobot/entity.py index 6f7c616b7a4..7991525c2a0 100644 --- a/homeassistant/components/uptimerobot/entity.py +++ b/homeassistant/components/uptimerobot/entity.py @@ -11,11 +11,10 @@ from . import UptimeRobotDataUpdateCoordinator from .const import ATTR_TARGET, ATTRIBUTION, DOMAIN -class UptimeRobotEntity(CoordinatorEntity): +class UptimeRobotEntity(CoordinatorEntity[UptimeRobotDataUpdateCoordinator]): """Base UptimeRobot entity.""" _attr_attribution = ATTRIBUTION - coordinator: UptimeRobotDataUpdateCoordinator def __init__( self, diff --git a/homeassistant/components/vallox/__init__.py b/homeassistant/components/vallox/__init__.py index aeb9e59e286..23e5cb53f97 100644 --- a/homeassistant/components/vallox/__init__.py +++ b/homeassistant/components/vallox/__init__.py @@ -131,11 +131,9 @@ class ValloxState: return next_filter_change_date -class ValloxDataUpdateCoordinator(DataUpdateCoordinator): +class ValloxDataUpdateCoordinator(DataUpdateCoordinator[ValloxState]): """The DataUpdateCoordinator for Vallox.""" - data: ValloxState - async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the integration from configuration.yaml (DEPRECATED).""" diff --git a/homeassistant/components/vallox/binary_sensor.py b/homeassistant/components/vallox/binary_sensor.py index e7b25ca2a80..348bad97158 100644 --- a/homeassistant/components/vallox/binary_sensor.py +++ b/homeassistant/components/vallox/binary_sensor.py @@ -16,11 +16,12 @@ from . import ValloxDataUpdateCoordinator from .const import DOMAIN -class ValloxBinarySensor(CoordinatorEntity, BinarySensorEntity): +class ValloxBinarySensor( + CoordinatorEntity[ValloxDataUpdateCoordinator], BinarySensorEntity +): """Representation of a Vallox binary sensor.""" entity_description: ValloxBinarySensorEntityDescription - coordinator: ValloxDataUpdateCoordinator def __init__( self, diff --git a/homeassistant/components/vallox/fan.py b/homeassistant/components/vallox/fan.py index 21e89f49d41..52535be3a29 100644 --- a/homeassistant/components/vallox/fan.py +++ b/homeassistant/components/vallox/fan.py @@ -80,11 +80,9 @@ async def async_setup_entry( async_add_entities([device]) -class ValloxFan(CoordinatorEntity, FanEntity): +class ValloxFan(CoordinatorEntity[ValloxDataUpdateCoordinator], FanEntity): """Representation of the fan.""" - coordinator: ValloxDataUpdateCoordinator - def __init__( self, name: str, diff --git a/homeassistant/components/vallox/sensor.py b/homeassistant/components/vallox/sensor.py index eece054c82e..92f0bc32e76 100644 --- a/homeassistant/components/vallox/sensor.py +++ b/homeassistant/components/vallox/sensor.py @@ -32,11 +32,10 @@ from .const import ( ) -class ValloxSensor(CoordinatorEntity, SensorEntity): +class ValloxSensor(CoordinatorEntity[ValloxDataUpdateCoordinator], SensorEntity): """Representation of a Vallox sensor.""" entity_description: ValloxSensorEntityDescription - coordinator: ValloxDataUpdateCoordinator def __init__( self, diff --git a/homeassistant/components/venstar/__init__.py b/homeassistant/components/venstar/__init__.py index 66a458f210a..759908c87e4 100644 --- a/homeassistant/components/venstar/__init__.py +++ b/homeassistant/components/venstar/__init__.py @@ -126,11 +126,9 @@ class VenstarDataUpdateCoordinator(update_coordinator.DataUpdateCoordinator): return None -class VenstarEntity(CoordinatorEntity): +class VenstarEntity(CoordinatorEntity[VenstarDataUpdateCoordinator]): """Representation of a Venstar entity.""" - coordinator: VenstarDataUpdateCoordinator - def __init__( self, venstar_data_coordinator: VenstarDataUpdateCoordinator, diff --git a/homeassistant/components/verisure/alarm_control_panel.py b/homeassistant/components/verisure/alarm_control_panel.py index e9cb2f49842..4cc5e8f6cb3 100644 --- a/homeassistant/components/verisure/alarm_control_panel.py +++ b/homeassistant/components/verisure/alarm_control_panel.py @@ -30,11 +30,11 @@ async def async_setup_entry( 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.""" - coordinator: VerisureDataUpdateCoordinator - _attr_code_format = FORMAT_NUMBER _attr_name = "Verisure Alarm" _attr_supported_features = SUPPORT_ALARM_ARM_HOME | SUPPORT_ALARM_ARM_AWAY diff --git a/homeassistant/components/verisure/binary_sensor.py b/homeassistant/components/verisure/binary_sensor.py index 05e0d77845a..217890b8a01 100644 --- a/homeassistant/components/verisure/binary_sensor.py +++ b/homeassistant/components/verisure/binary_sensor.py @@ -33,11 +33,11 @@ async def async_setup_entry( async_add_entities(sensors) -class VerisureDoorWindowSensor(CoordinatorEntity, BinarySensorEntity): +class VerisureDoorWindowSensor( + CoordinatorEntity[VerisureDataUpdateCoordinator], BinarySensorEntity +): """Representation of a Verisure door window sensor.""" - coordinator: VerisureDataUpdateCoordinator - _attr_device_class = BinarySensorDeviceClass.OPENING 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.""" - coordinator: VerisureDataUpdateCoordinator - _attr_name = "Verisure Ethernet status" _attr_device_class = BinarySensorDeviceClass.CONNECTIVITY _attr_entity_category = EntityCategory.DIAGNOSTIC diff --git a/homeassistant/components/verisure/camera.py b/homeassistant/components/verisure/camera.py index 787e496202f..c753bf2c5dc 100644 --- a/homeassistant/components/verisure/camera.py +++ b/homeassistant/components/verisure/camera.py @@ -43,11 +43,9 @@ async def async_setup_entry( ) -class VerisureSmartcam(CoordinatorEntity, Camera): +class VerisureSmartcam(CoordinatorEntity[VerisureDataUpdateCoordinator], Camera): """Representation of a Verisure camera.""" - coordinator: VerisureDataUpdateCoordinator - def __init__( self, coordinator: VerisureDataUpdateCoordinator, diff --git a/homeassistant/components/verisure/lock.py b/homeassistant/components/verisure/lock.py index 86b232d54fd..0e28298b2e8 100644 --- a/homeassistant/components/verisure/lock.py +++ b/homeassistant/components/verisure/lock.py @@ -55,11 +55,9 @@ async def async_setup_entry( ) -class VerisureDoorlock(CoordinatorEntity, LockEntity): +class VerisureDoorlock(CoordinatorEntity[VerisureDataUpdateCoordinator], LockEntity): """Representation of a Verisure doorlock.""" - coordinator: VerisureDataUpdateCoordinator - def __init__( self, coordinator: VerisureDataUpdateCoordinator, serial_number: str ) -> None: diff --git a/homeassistant/components/verisure/sensor.py b/homeassistant/components/verisure/sensor.py index 9e19e5d865f..3b8f722c6f7 100644 --- a/homeassistant/components/verisure/sensor.py +++ b/homeassistant/components/verisure/sensor.py @@ -45,11 +45,11 @@ async def async_setup_entry( async_add_entities(sensors) -class VerisureThermometer(CoordinatorEntity, SensorEntity): +class VerisureThermometer( + CoordinatorEntity[VerisureDataUpdateCoordinator], SensorEntity +): """Representation of a Verisure thermometer.""" - coordinator: VerisureDataUpdateCoordinator - _attr_device_class = SensorDeviceClass.TEMPERATURE _attr_native_unit_of_measurement = TEMP_CELSIUS _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.""" - coordinator: VerisureDataUpdateCoordinator - _attr_device_class = SensorDeviceClass.HUMIDITY _attr_native_unit_of_measurement = PERCENTAGE _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.""" - coordinator: VerisureDataUpdateCoordinator - _attr_native_unit_of_measurement = "Mice" def __init__( diff --git a/homeassistant/components/verisure/switch.py b/homeassistant/components/verisure/switch.py index 777195d1a51..5d1fd728f4a 100644 --- a/homeassistant/components/verisure/switch.py +++ b/homeassistant/components/verisure/switch.py @@ -27,11 +27,9 @@ async def async_setup_entry( ) -class VerisureSmartplug(CoordinatorEntity, SwitchEntity): +class VerisureSmartplug(CoordinatorEntity[VerisureDataUpdateCoordinator], SwitchEntity): """Representation of a Verisure smartplug.""" - coordinator: VerisureDataUpdateCoordinator - def __init__( self, coordinator: VerisureDataUpdateCoordinator, serial_number: str ) -> None: diff --git a/homeassistant/components/version/entity.py b/homeassistant/components/version/entity.py index 1dcdc23fa9f..d950c6394b8 100644 --- a/homeassistant/components/version/entity.py +++ b/homeassistant/components/version/entity.py @@ -8,7 +8,7 @@ from .const import DOMAIN, HOME_ASSISTANT from .coordinator import VersionDataUpdateCoordinator -class VersionEntity(CoordinatorEntity): +class VersionEntity(CoordinatorEntity[VersionDataUpdateCoordinator]): """Common entity class for Version integration.""" _attr_device_info = DeviceInfo( @@ -18,8 +18,6 @@ class VersionEntity(CoordinatorEntity): entry_type=DeviceEntryType.SERVICE, ) - coordinator: VersionDataUpdateCoordinator - def __init__( self, coordinator: VersionDataUpdateCoordinator,