Update coordinator typing (3) [g-n] ()

pull/68469/head
Marc Mueller 2022-03-21 14:14:46 +01:00 committed by GitHub
parent 354fc4c1ae
commit 0d29b7cbb3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 25 additions and 29 deletions
homeassistant/components
gogogate2
intellifire
iotawatt
launch_library
lookin
moehlenhoff_alpha2
nsw_fuel_station

View File

@ -69,10 +69,9 @@ async def async_setup_entry(
async_add_entities(sensors)
class GiosSensor(CoordinatorEntity, SensorEntity):
class GiosSensor(CoordinatorEntity[GiosDataUpdateCoordinator], SensorEntity):
"""Define an GIOS sensor."""
coordinator: GiosDataUpdateCoordinator
entity_description: GiosSensorEntityDescription
def __init__(

View File

@ -66,7 +66,7 @@ class DeviceDataUpdateCoordinator(DataUpdateCoordinator):
self.api = api
class GoGoGate2Entity(CoordinatorEntity):
class GoGoGate2Entity(CoordinatorEntity[DeviceDataUpdateCoordinator]):
"""Base class for gogogate2 entities."""
def __init__(

View File

@ -7,7 +7,7 @@ from .bridge import DeviceDataUpdateCoordinator
from .const import DOMAIN
class GreeEntity(CoordinatorEntity):
class GreeEntity(CoordinatorEntity[DeviceDataUpdateCoordinator]):
"""Generic Gree entity (base class)."""
def __init__(self, coordinator: DeviceDataUpdateCoordinator, desc: str) -> None:

View File

@ -7,10 +7,9 @@ from homeassistant.helpers.update_coordinator import CoordinatorEntity
from . import IntellifireDataUpdateCoordinator
class IntellifireEntity(CoordinatorEntity):
class IntellifireEntity(CoordinatorEntity[IntellifireDataUpdateCoordinator]):
"""Define a generic class for Intellifire entities."""
coordinator: IntellifireDataUpdateCoordinator
_attr_attribution = "Data provided by unpublished Intellifire API"
def __init__(

View File

@ -24,11 +24,12 @@ from homeassistant.const import (
POWER_WATT,
)
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import entity, entity_registry, update_coordinator
from homeassistant.helpers import entity, entity_registry
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.restore_state import RestoreEntity
from homeassistant.helpers.typing import StateType
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from homeassistant.util import dt
from .const import (
@ -159,11 +160,10 @@ async def async_setup_entry(
coordinator.async_add_listener(new_data_received)
class IotaWattSensor(update_coordinator.CoordinatorEntity, SensorEntity):
class IotaWattSensor(CoordinatorEntity[IotawattUpdater], SensorEntity):
"""Defines a IoTaWatt Energy Sensor."""
entity_description: IotaWattSensorEntityDescription
coordinator: IotawattUpdater
def __init__(
self,

View File

@ -8,7 +8,7 @@ from .const import DOMAIN
from .coordinator import IPPDataUpdateCoordinator
class IPPEntity(CoordinatorEntity):
class IPPEntity(CoordinatorEntity[IPPDataUpdateCoordinator]):
"""Defines a base IPP entity."""
def __init__(

View File

@ -179,13 +179,14 @@ async def async_setup_entry(
)
class LaunchLibrarySensor(CoordinatorEntity, SensorEntity):
class LaunchLibrarySensor(
CoordinatorEntity[DataUpdateCoordinator[LaunchLibraryData]], SensorEntity
):
"""Representation of the next launch sensors."""
_attr_attribution = "Data provided by Launch Library."
_next_event: Launch | Event | None = None
entity_description: LaunchLibrarySensorEntityDescription
coordinator: DataUpdateCoordinator[LaunchLibraryData]
def __init__(
self,

View File

@ -52,11 +52,11 @@ class LookinDeviceMixIn:
self._lookin_udp_subs = lookin_data.lookin_udp_subs
class LookinDeviceCoordinatorEntity(LookinDeviceMixIn, CoordinatorEntity):
class LookinDeviceCoordinatorEntity(
LookinDeviceMixIn, CoordinatorEntity[LookinDataUpdateCoordinator]
):
"""A lookin device entity on the device itself that uses the coordinator."""
coordinator: LookinDataUpdateCoordinator
_attr_should_poll = False
def __init__(self, lookin_data: LookinData) -> None:
@ -84,11 +84,11 @@ class LookinEntityMixIn:
self._function_names = {function.name for function in self._device.functions}
class LookinCoordinatorEntity(LookinDeviceMixIn, LookinEntityMixIn, CoordinatorEntity):
class LookinCoordinatorEntity(
LookinDeviceMixIn, LookinEntityMixIn, CoordinatorEntity[LookinDataUpdateCoordinator]
):
"""A lookin device entity for an external device that uses the coordinator."""
coordinator: LookinDataUpdateCoordinator
_attr_should_poll = False
_attr_assumed_state = True

View File

@ -38,10 +38,9 @@ async def async_setup_entry(
# https://developers.home-assistant.io/docs/core/entity/climate/
class Alpha2Climate(CoordinatorEntity, ClimateEntity):
class Alpha2Climate(CoordinatorEntity[Alpha2BaseCoordinator], ClimateEntity):
"""Alpha2 ClimateEntity."""
coordinator: Alpha2BaseCoordinator
target_temperature_step = 0.2
_attr_supported_features = SUPPORT_TARGET_TEMPERATURE | SUPPORT_PRESET_MODE

View File

@ -41,11 +41,9 @@ async def async_setup_entry(
async_add_entities(buttons, False)
class NAMButton(CoordinatorEntity, ButtonEntity):
class NAMButton(CoordinatorEntity[NAMDataUpdateCoordinator], ButtonEntity):
"""Define an Nettigo Air Monitor button."""
coordinator: NAMDataUpdateCoordinator
def __init__(
self,
coordinator: NAMDataUpdateCoordinator,

View File

@ -58,11 +58,9 @@ async def async_setup_entry(
async_add_entities(sensors, False)
class NAMSensor(CoordinatorEntity, SensorEntity):
class NAMSensor(CoordinatorEntity[NAMDataUpdateCoordinator], SensorEntity):
"""Define an Nettigo Air Monitor sensor."""
coordinator: NAMDataUpdateCoordinator
def __init__(
self,
coordinator: NAMDataUpdateCoordinator,

View File

@ -46,7 +46,7 @@ async def async_setup_entry(
async_add_entities(entities)
class NINAMessage(CoordinatorEntity, BinarySensorEntity):
class NINAMessage(CoordinatorEntity[NINADataUpdateCoordinator], BinarySensorEntity):
"""Representation of an NINA warning."""
def __init__(

View File

@ -83,7 +83,9 @@ def setup_platform(
add_entities(entities)
class StationPriceSensor(CoordinatorEntity, SensorEntity):
class StationPriceSensor(
CoordinatorEntity[DataUpdateCoordinator[StationPriceData]], SensorEntity
):
"""Implementation of a sensor that reports the fuel price for a station."""
def __init__(

View File

@ -154,7 +154,7 @@ async def _async_update_listener(hass: HomeAssistant, entry: ConfigEntry) -> Non
await hass.config_entries.async_reload(entry.entry_id)
class NZBGetEntity(CoordinatorEntity):
class NZBGetEntity(CoordinatorEntity[NZBGetDataUpdateCoordinator]):
"""Defines a base NZBGet entity."""
def __init__(