Update coordinator typing (4) [o-p] (#68464)

This commit is contained in:
Marc Mueller 2022-03-21 14:45:24 +01:00 committed by GitHub
parent 2424564d2c
commit b664bcd007
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 33 additions and 32 deletions

View File

@ -36,11 +36,11 @@ async def async_setup_entry(
async_add_entities(entities) async_add_entities(entities)
class OctoPrintBinarySensorBase(CoordinatorEntity, BinarySensorEntity): class OctoPrintBinarySensorBase(
CoordinatorEntity[OctoprintDataUpdateCoordinator], BinarySensorEntity
):
"""Representation an OctoPrint binary sensor.""" """Representation an OctoPrint binary sensor."""
coordinator: OctoprintDataUpdateCoordinator
def __init__( def __init__(
self, self,
coordinator: OctoprintDataUpdateCoordinator, coordinator: OctoprintDataUpdateCoordinator,

View File

@ -34,10 +34,9 @@ async def async_setup_entry(
) )
class OctoprintButton(CoordinatorEntity, ButtonEntity): class OctoprintButton(CoordinatorEntity[OctoprintDataUpdateCoordinator], ButtonEntity):
"""Represent an OctoPrint binary sensor.""" """Represent an OctoPrint binary sensor."""
coordinator: OctoprintDataUpdateCoordinator
client: OctoprintClient client: OctoprintClient
def __init__( def __init__(

View File

@ -89,11 +89,11 @@ async def async_setup_entry(
async_add_entities(entities) async_add_entities(entities)
class OctoPrintSensorBase(CoordinatorEntity, SensorEntity): class OctoPrintSensorBase(
CoordinatorEntity[OctoprintDataUpdateCoordinator], SensorEntity
):
"""Representation of an OctoPrint sensor.""" """Representation of an OctoPrint sensor."""
coordinator: OctoprintDataUpdateCoordinator
def __init__( def __init__(
self, self,
coordinator: OctoprintDataUpdateCoordinator, coordinator: OctoprintDataUpdateCoordinator,

View File

@ -73,7 +73,7 @@ class OmniLogicUpdateCoordinator(DataUpdateCoordinator):
return parsed_data return parsed_data
class OmniLogicEntity(CoordinatorEntity): class OmniLogicEntity(CoordinatorEntity[OmniLogicUpdateCoordinator]):
"""Defines the base OmniLogic entity.""" """Defines the base OmniLogic entity."""
def __init__( def __init__(

View File

@ -28,14 +28,18 @@ async def async_setup_entry(
async_add_entities([OpenMeteoWeatherEntity(entry=entry, coordinator=coordinator)]) async_add_entities([OpenMeteoWeatherEntity(entry=entry, coordinator=coordinator)])
class OpenMeteoWeatherEntity(CoordinatorEntity, WeatherEntity): class OpenMeteoWeatherEntity(
CoordinatorEntity[DataUpdateCoordinator[OpenMeteoForecast]], WeatherEntity
):
"""Defines an Open-Meteo weather entity.""" """Defines an Open-Meteo weather entity."""
_attr_temperature_unit = TEMP_CELSIUS _attr_temperature_unit = TEMP_CELSIUS
coordinator: DataUpdateCoordinator[OpenMeteoForecast]
def __init__( def __init__(
self, *, entry: ConfigEntry, coordinator: DataUpdateCoordinator self,
*,
entry: ConfigEntry,
coordinator: DataUpdateCoordinator[OpenMeteoForecast],
) -> None: ) -> None:
"""Initialize Open-Meteo weather entity.""" """Initialize Open-Meteo weather entity."""
super().__init__(coordinator=coordinator) super().__init__(coordinator=coordinator)

View File

@ -16,11 +16,9 @@ from .coordinator import OverkizDataUpdateCoordinator
from .executor import OverkizExecutor from .executor import OverkizExecutor
class OverkizEntity(CoordinatorEntity): class OverkizEntity(CoordinatorEntity[OverkizDataUpdateCoordinator]):
"""Representation of an Overkiz device entity.""" """Representation of an Overkiz device entity."""
coordinator: OverkizDataUpdateCoordinator
def __init__( def __init__(
self, device_url: str, coordinator: OverkizDataUpdateCoordinator self, device_url: str, coordinator: OverkizDataUpdateCoordinator
) -> None: ) -> None:

View File

@ -235,11 +235,11 @@ async def async_setup_entry(
) )
class P1MonitorSensorEntity(CoordinatorEntity, SensorEntity): class P1MonitorSensorEntity(
CoordinatorEntity[P1MonitorDataUpdateCoordinator], SensorEntity
):
"""Defines an P1 Monitor sensor.""" """Defines an P1 Monitor sensor."""
coordinator: P1MonitorDataUpdateCoordinator
def __init__( def __init__(
self, self,
*, *,

View File

@ -123,7 +123,9 @@ def _average_pixels(data):
return 0.0, 0.0, 0.0 return 0.0, 0.0, 0.0
class PhilipsTVLightEntity(CoordinatorEntity, LightEntity): class PhilipsTVLightEntity(
CoordinatorEntity[PhilipsTVDataUpdateCoordinator], LightEntity
):
"""Representation of a Philips TV exposing the JointSpace API.""" """Representation of a Philips TV exposing the JointSpace API."""
def __init__( def __init__(

View File

@ -79,10 +79,11 @@ async def async_setup_entry(
) )
class PhilipsTVMediaPlayer(CoordinatorEntity, MediaPlayerEntity): class PhilipsTVMediaPlayer(
CoordinatorEntity[PhilipsTVDataUpdateCoordinator], MediaPlayerEntity
):
"""Representation of a Philips TV exposing the JointSpace API.""" """Representation of a Philips TV exposing the JointSpace API."""
coordinator: PhilipsTVDataUpdateCoordinator
_attr_device_class = MediaPlayerDeviceClass.TV _attr_device_class = MediaPlayerDeviceClass.TV
def __init__( def __init__(

View File

@ -27,11 +27,9 @@ async def async_setup_entry(
async_add_entities([PhilipsTVRemote(coordinator)]) async_add_entities([PhilipsTVRemote(coordinator)])
class PhilipsTVRemote(CoordinatorEntity, RemoteEntity): class PhilipsTVRemote(CoordinatorEntity[PhilipsTVDataUpdateCoordinator], RemoteEntity):
"""Device that sends commands.""" """Device that sends commands."""
coordinator: PhilipsTVDataUpdateCoordinator
def __init__( def __init__(
self, self,
coordinator: PhilipsTVDataUpdateCoordinator, coordinator: PhilipsTVDataUpdateCoordinator,

View File

@ -27,11 +27,11 @@ async def async_setup_entry(
async_add_entities([PhilipsTVScreenSwitch(coordinator)]) async_add_entities([PhilipsTVScreenSwitch(coordinator)])
class PhilipsTVScreenSwitch(CoordinatorEntity, SwitchEntity): class PhilipsTVScreenSwitch(
CoordinatorEntity[PhilipsTVDataUpdateCoordinator], SwitchEntity
):
"""A Philips TV screen state switch.""" """A Philips TV screen state switch."""
coordinator: PhilipsTVDataUpdateCoordinator
def __init__( def __init__(
self, self,
coordinator: PhilipsTVDataUpdateCoordinator, coordinator: PhilipsTVDataUpdateCoordinator,

View File

@ -133,10 +133,11 @@ async def async_setup_entry(
) )
class PVOutputSensorEntity(CoordinatorEntity, SensorEntity): class PVOutputSensorEntity(
CoordinatorEntity[PVOutputDataUpdateCoordinator], SensorEntity
):
"""Representation of a PVOutput sensor.""" """Representation of a PVOutput sensor."""
coordinator: PVOutputDataUpdateCoordinator
entity_description: PVOutputSensorEntityDescription entity_description: PVOutputSensorEntityDescription
def __init__( def __init__(

View File

@ -125,11 +125,9 @@ async def async_setup_entry(
) )
class ElecPriceSensor(CoordinatorEntity, SensorEntity): class ElecPriceSensor(CoordinatorEntity[ElecPricesDataUpdateCoordinator], SensorEntity):
"""Class to hold the prices of electricity as a sensor.""" """Class to hold the prices of electricity as a sensor."""
coordinator: ElecPricesDataUpdateCoordinator
def __init__( def __init__(
self, self,
coordinator: ElecPricesDataUpdateCoordinator, coordinator: ElecPricesDataUpdateCoordinator,