Improve DataUpdateCoordinator typing in integrations (8) (#85331)
This commit is contained in:
parent
2e989b16ad
commit
c3991b591a
10 changed files with 27 additions and 14 deletions
|
@ -154,7 +154,7 @@ class AirthingsSensor(
|
|||
|
||||
def __init__(
|
||||
self,
|
||||
coordinator: DataUpdateCoordinator,
|
||||
coordinator: DataUpdateCoordinator[AirthingsDevice],
|
||||
airthings_device: AirthingsDevice,
|
||||
entity_description: SensorEntityDescription,
|
||||
) -> None:
|
||||
|
|
|
@ -46,7 +46,9 @@ async def async_setup_entry(
|
|||
)
|
||||
|
||||
|
||||
class LD2410BLEBinarySensor(CoordinatorEntity, BinarySensorEntity):
|
||||
class LD2410BLEBinarySensor(
|
||||
CoordinatorEntity[LD2410BLECoordinator], BinarySensorEntity
|
||||
):
|
||||
"""Moving/static sensor for LD2410BLE."""
|
||||
|
||||
def __init__(
|
||||
|
|
|
@ -12,7 +12,7 @@ from .const import DOMAIN
|
|||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class LD2410BLECoordinator(DataUpdateCoordinator):
|
||||
class LD2410BLECoordinator(DataUpdateCoordinator[None]):
|
||||
"""Data coordinator for receiving LD2410B updates."""
|
||||
|
||||
def __init__(self, hass: HomeAssistant, ld2410_ble: LD2410BLE) -> None:
|
||||
|
@ -31,7 +31,7 @@ class LD2410BLECoordinator(DataUpdateCoordinator):
|
|||
def _async_handle_update(self, state: LD2410BLEState) -> None:
|
||||
"""Just trigger the callbacks."""
|
||||
self.connected = True
|
||||
self.async_set_updated_data(True)
|
||||
self.async_set_updated_data(None)
|
||||
|
||||
@callback
|
||||
def _async_handle_disconnect(self) -> None:
|
||||
|
|
|
@ -41,7 +41,7 @@ class NanoleafEntryData:
|
|||
"""Class for sharing data within the Nanoleaf integration."""
|
||||
|
||||
device: Nanoleaf
|
||||
coordinator: DataUpdateCoordinator
|
||||
coordinator: DataUpdateCoordinator[None]
|
||||
event_listener: asyncio.Task
|
||||
|
||||
|
||||
|
|
|
@ -27,7 +27,9 @@ async def async_setup_entry(
|
|||
class NanoleafIdentifyButton(NanoleafEntity, ButtonEntity):
|
||||
"""Representation of a Nanoleaf identify button."""
|
||||
|
||||
def __init__(self, nanoleaf: Nanoleaf, coordinator: DataUpdateCoordinator) -> None:
|
||||
def __init__(
|
||||
self, nanoleaf: Nanoleaf, coordinator: DataUpdateCoordinator[None]
|
||||
) -> None:
|
||||
"""Initialize the Nanoleaf button."""
|
||||
super().__init__(nanoleaf, coordinator)
|
||||
self._attr_unique_id = f"{nanoleaf.serial_no}_identify"
|
||||
|
|
|
@ -11,10 +11,12 @@ from homeassistant.helpers.update_coordinator import (
|
|||
from .const import DOMAIN
|
||||
|
||||
|
||||
class NanoleafEntity(CoordinatorEntity):
|
||||
class NanoleafEntity(CoordinatorEntity[DataUpdateCoordinator[None]]):
|
||||
"""Representation of a Nanoleaf entity."""
|
||||
|
||||
def __init__(self, nanoleaf: Nanoleaf, coordinator: DataUpdateCoordinator) -> None:
|
||||
def __init__(
|
||||
self, nanoleaf: Nanoleaf, coordinator: DataUpdateCoordinator[None]
|
||||
) -> None:
|
||||
"""Initialize an Nanoleaf entity."""
|
||||
super().__init__(coordinator)
|
||||
self._nanoleaf = nanoleaf
|
||||
|
|
|
@ -47,7 +47,9 @@ class NanoleafLight(NanoleafEntity, LightEntity):
|
|||
_attr_supported_color_modes = {ColorMode.COLOR_TEMP, ColorMode.HS}
|
||||
_attr_supported_features = LightEntityFeature.EFFECT | LightEntityFeature.TRANSITION
|
||||
|
||||
def __init__(self, nanoleaf: Nanoleaf, coordinator: DataUpdateCoordinator) -> None:
|
||||
def __init__(
|
||||
self, nanoleaf: Nanoleaf, coordinator: DataUpdateCoordinator[None]
|
||||
) -> None:
|
||||
"""Initialize the Nanoleaf light."""
|
||||
super().__init__(nanoleaf, coordinator)
|
||||
self._attr_unique_id = nanoleaf.serial_no
|
||||
|
|
|
@ -489,7 +489,7 @@ class SimpliSafe:
|
|||
self.systems: dict[int, SystemType] = {}
|
||||
|
||||
# This will get filled in by async_init:
|
||||
self.coordinator: DataUpdateCoordinator | None = None
|
||||
self.coordinator: DataUpdateCoordinator[None] | None = None
|
||||
|
||||
@callback
|
||||
def _async_process_new_notifications(self, system: SystemType) -> None:
|
||||
|
@ -692,7 +692,7 @@ class SimpliSafe:
|
|||
raise UpdateFailed(f"SimpliSafe error while updating: {result}")
|
||||
|
||||
|
||||
class SimpliSafeEntity(CoordinatorEntity):
|
||||
class SimpliSafeEntity(CoordinatorEntity[DataUpdateCoordinator[None]]):
|
||||
"""Define a base SimpliSafe entity."""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
|
|
|
@ -24,7 +24,7 @@ from .const import (
|
|||
class SolarEdgeDataService(ABC):
|
||||
"""Get and update the latest data."""
|
||||
|
||||
coordinator: DataUpdateCoordinator
|
||||
coordinator: DataUpdateCoordinator[None]
|
||||
|
||||
def __init__(self, hass: HomeAssistant, api: Solaredge, site_id: str) -> None:
|
||||
"""Initialize the data object."""
|
||||
|
|
|
@ -9,7 +9,10 @@ from homeassistant.components.sensor import SensorDeviceClass, SensorEntity
|
|||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
from homeassistant.helpers.update_coordinator import (
|
||||
CoordinatorEntity,
|
||||
DataUpdateCoordinator,
|
||||
)
|
||||
|
||||
from .const import CONF_SITE_ID, DATA_API_CLIENT, DOMAIN, SENSOR_TYPES
|
||||
from .coordinator import (
|
||||
|
@ -108,7 +111,9 @@ class SolarEdgeSensorFactory:
|
|||
return sensor_class(self.platform_name, sensor_type, service)
|
||||
|
||||
|
||||
class SolarEdgeSensorEntity(CoordinatorEntity, SensorEntity):
|
||||
class SolarEdgeSensorEntity(
|
||||
CoordinatorEntity[DataUpdateCoordinator[None]], SensorEntity
|
||||
):
|
||||
"""Abstract class for a solaredge sensor."""
|
||||
|
||||
entity_description: SolarEdgeSensorEntityDescription
|
||||
|
|
Loading…
Add table
Reference in a new issue