Improve `rainbird` generic typing (#84642)
parent
a06b1eaf69
commit
24a34b1739
|
@ -2,6 +2,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Union
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
BinarySensorEntity,
|
||||
|
@ -10,12 +11,10 @@ from homeassistant.components.binary_sensor import (
|
|||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
from homeassistant.helpers.update_coordinator import (
|
||||
CoordinatorEntity,
|
||||
DataUpdateCoordinator,
|
||||
)
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import SENSOR_TYPE_RAINDELAY, SENSOR_TYPE_RAINSENSOR
|
||||
from .coordinator import RainbirdUpdateCoordinator
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -53,12 +52,14 @@ async def async_setup_platform(
|
|||
)
|
||||
|
||||
|
||||
class RainBirdSensor(CoordinatorEntity, BinarySensorEntity):
|
||||
class RainBirdSensor(
|
||||
CoordinatorEntity[RainbirdUpdateCoordinator[Union[int, bool]]], BinarySensorEntity
|
||||
):
|
||||
"""A sensor implementation for Rain Bird device."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
coordinator: DataUpdateCoordinator,
|
||||
coordinator: RainbirdUpdateCoordinator[int | bool],
|
||||
description: BinarySensorEntityDescription,
|
||||
) -> None:
|
||||
"""Initialize the Rain Bird sensor."""
|
||||
|
|
|
@ -2,17 +2,16 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Union
|
||||
|
||||
from homeassistant.components.sensor import SensorEntity, SensorEntityDescription
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType, StateType
|
||||
from homeassistant.helpers.update_coordinator import (
|
||||
CoordinatorEntity,
|
||||
DataUpdateCoordinator,
|
||||
)
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import SENSOR_TYPE_RAINDELAY, SENSOR_TYPE_RAINSENSOR
|
||||
from .coordinator import RainbirdUpdateCoordinator
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -51,12 +50,14 @@ async def async_setup_platform(
|
|||
)
|
||||
|
||||
|
||||
class RainBirdSensor(CoordinatorEntity, SensorEntity):
|
||||
class RainBirdSensor(
|
||||
CoordinatorEntity[RainbirdUpdateCoordinator[Union[int, bool]]], SensorEntity
|
||||
):
|
||||
"""A sensor implementation for Rain Bird device."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
coordinator: DataUpdateCoordinator,
|
||||
coordinator: RainbirdUpdateCoordinator[int | bool],
|
||||
description: SensorEntityDescription,
|
||||
) -> None:
|
||||
"""Initialize the Rain Bird sensor."""
|
||||
|
|
|
@ -113,7 +113,9 @@ async def async_setup_platform(
|
|||
)
|
||||
|
||||
|
||||
class RainBirdSwitch(CoordinatorEntity, SwitchEntity):
|
||||
class RainBirdSwitch(
|
||||
CoordinatorEntity[RainbirdUpdateCoordinator[States]], SwitchEntity
|
||||
):
|
||||
"""Representation of a Rain Bird switch."""
|
||||
|
||||
def __init__(
|
||||
|
|
Loading…
Reference in New Issue