Remove entity description mixin in Ecoforest (#112409)
This commit is contained in:
parent
362a10e82e
commit
dd3c11f179
3 changed files with 9 additions and 30 deletions
|
@ -16,20 +16,13 @@ from .coordinator import EcoforestCoordinator
|
||||||
from .entity import EcoforestEntity
|
from .entity import EcoforestEntity
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class EcoforestRequiredKeysMixin:
|
class EcoforestNumberEntityDescription(NumberEntityDescription):
|
||||||
"""Mixin for required keys."""
|
"""Describes an ecoforest number entity."""
|
||||||
|
|
||||||
value_fn: Callable[[Device], float | None]
|
value_fn: Callable[[Device], float | None]
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
|
||||||
class EcoforestNumberEntityDescription(
|
|
||||||
NumberEntityDescription, EcoforestRequiredKeysMixin
|
|
||||||
):
|
|
||||||
"""Describes an ecoforest number entity."""
|
|
||||||
|
|
||||||
|
|
||||||
NUMBER_ENTITIES = (
|
NUMBER_ENTITIES = (
|
||||||
EcoforestNumberEntityDescription(
|
EcoforestNumberEntityDescription(
|
||||||
key="power_level",
|
key="power_level",
|
||||||
|
|
|
@ -33,20 +33,13 @@ STATUS_TYPE = [s.value for s in State]
|
||||||
ALARM_TYPE = [a.value for a in Alarm] + ["none"]
|
ALARM_TYPE = [a.value for a in Alarm] + ["none"]
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class EcoforestRequiredKeysMixin:
|
class EcoforestSensorEntityDescription(SensorEntityDescription):
|
||||||
"""Mixin for required keys."""
|
"""Describes Ecoforest sensor entity."""
|
||||||
|
|
||||||
value_fn: Callable[[Device], StateType]
|
value_fn: Callable[[Device], StateType]
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
|
||||||
class EcoforestSensorEntityDescription(
|
|
||||||
SensorEntityDescription, EcoforestRequiredKeysMixin
|
|
||||||
):
|
|
||||||
"""Describes Ecoforest sensor entity."""
|
|
||||||
|
|
||||||
|
|
||||||
SENSOR_TYPES: tuple[EcoforestSensorEntityDescription, ...] = (
|
SENSOR_TYPES: tuple[EcoforestSensorEntityDescription, ...] = (
|
||||||
EcoforestSensorEntityDescription(
|
EcoforestSensorEntityDescription(
|
||||||
key="temperature",
|
key="temperature",
|
||||||
|
|
|
@ -17,21 +17,14 @@ from .coordinator import EcoforestCoordinator
|
||||||
from .entity import EcoforestEntity
|
from .entity import EcoforestEntity
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class EcoforestSwitchRequiredKeysMixin:
|
class EcoforestSwitchEntityDescription(SwitchEntityDescription):
|
||||||
"""Mixin for required keys."""
|
"""Describes an Ecoforest switch entity."""
|
||||||
|
|
||||||
value_fn: Callable[[Device], bool]
|
value_fn: Callable[[Device], bool]
|
||||||
switch_fn: Callable[[EcoforestApi, bool], Awaitable[Device]]
|
switch_fn: Callable[[EcoforestApi, bool], Awaitable[Device]]
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
|
||||||
class EcoforestSwitchEntityDescription(
|
|
||||||
SwitchEntityDescription, EcoforestSwitchRequiredKeysMixin
|
|
||||||
):
|
|
||||||
"""Describes an Ecoforest switch entity."""
|
|
||||||
|
|
||||||
|
|
||||||
SWITCH_TYPES: tuple[EcoforestSwitchEntityDescription, ...] = (
|
SWITCH_TYPES: tuple[EcoforestSwitchEntityDescription, ...] = (
|
||||||
EcoforestSwitchEntityDescription(
|
EcoforestSwitchEntityDescription(
|
||||||
key="status",
|
key="status",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue