mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 18:27:09 +00:00
Remove entity description mixin in Enphase Envoy (#112486)
This commit is contained in:
parent
8e26e36033
commit
39cad5f1ee
@ -22,20 +22,13 @@ from .coordinator import EnphaseUpdateCoordinator
|
|||||||
from .entity import EnvoyBaseEntity
|
from .entity import EnvoyBaseEntity
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class EnvoyEnchargeRequiredKeysMixin:
|
class EnvoyEnchargeBinarySensorEntityDescription(BinarySensorEntityDescription):
|
||||||
"""Mixin for required keys."""
|
"""Describes an Envoy Encharge binary sensor entity."""
|
||||||
|
|
||||||
value_fn: Callable[[EnvoyEncharge], bool]
|
value_fn: Callable[[EnvoyEncharge], bool]
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
|
||||||
class EnvoyEnchargeBinarySensorEntityDescription(
|
|
||||||
BinarySensorEntityDescription, EnvoyEnchargeRequiredKeysMixin
|
|
||||||
):
|
|
||||||
"""Describes an Envoy Encharge binary sensor entity."""
|
|
||||||
|
|
||||||
|
|
||||||
ENCHARGE_SENSORS = (
|
ENCHARGE_SENSORS = (
|
||||||
EnvoyEnchargeBinarySensorEntityDescription(
|
EnvoyEnchargeBinarySensorEntityDescription(
|
||||||
key="communicating",
|
key="communicating",
|
||||||
@ -53,20 +46,13 @@ ENCHARGE_SENSORS = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class EnvoyEnpowerRequiredKeysMixin:
|
class EnvoyEnpowerBinarySensorEntityDescription(BinarySensorEntityDescription):
|
||||||
"""Mixin for required keys."""
|
"""Describes an Envoy Enpower binary sensor entity."""
|
||||||
|
|
||||||
value_fn: Callable[[EnvoyEnpower], bool]
|
value_fn: Callable[[EnvoyEnpower], bool]
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
|
||||||
class EnvoyEnpowerBinarySensorEntityDescription(
|
|
||||||
BinarySensorEntityDescription, EnvoyEnpowerRequiredKeysMixin
|
|
||||||
):
|
|
||||||
"""Describes an Envoy Enpower binary sensor entity."""
|
|
||||||
|
|
||||||
|
|
||||||
ENPOWER_SENSORS = (
|
ENPOWER_SENSORS = (
|
||||||
EnvoyEnpowerBinarySensorEntityDescription(
|
EnvoyEnpowerBinarySensorEntityDescription(
|
||||||
key="communicating",
|
key="communicating",
|
||||||
|
@ -25,35 +25,21 @@ from .coordinator import EnphaseUpdateCoordinator
|
|||||||
from .entity import EnvoyBaseEntity
|
from .entity import EnvoyBaseEntity
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class EnvoyRelayRequiredKeysMixin:
|
class EnvoyRelayNumberEntityDescription(NumberEntityDescription):
|
||||||
"""Mixin for required keys."""
|
"""Describes an Envoy Dry Contact Relay number entity."""
|
||||||
|
|
||||||
value_fn: Callable[[EnvoyDryContactSettings], float]
|
value_fn: Callable[[EnvoyDryContactSettings], float]
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class EnvoyRelayNumberEntityDescription(
|
class EnvoyStorageSettingsNumberEntityDescription(NumberEntityDescription):
|
||||||
NumberEntityDescription, EnvoyRelayRequiredKeysMixin
|
"""Describes an Envoy storage mode number entity."""
|
||||||
):
|
|
||||||
"""Describes an Envoy Dry Contact Relay number entity."""
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
|
||||||
class EnvoyStorageSettingsRequiredKeysMixin:
|
|
||||||
"""Mixin for required keys."""
|
|
||||||
|
|
||||||
value_fn: Callable[[EnvoyStorageSettings], float]
|
value_fn: Callable[[EnvoyStorageSettings], float]
|
||||||
update_fn: Callable[[Envoy, float], Awaitable[dict[str, Any]]]
|
update_fn: Callable[[Envoy, float], Awaitable[dict[str, Any]]]
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
|
||||||
class EnvoyStorageSettingsNumberEntityDescription(
|
|
||||||
NumberEntityDescription, EnvoyStorageSettingsRequiredKeysMixin
|
|
||||||
):
|
|
||||||
"""Describes an Envoy storage mode number entity."""
|
|
||||||
|
|
||||||
|
|
||||||
RELAY_ENTITIES = (
|
RELAY_ENTITIES = (
|
||||||
EnvoyRelayNumberEntityDescription(
|
EnvoyRelayNumberEntityDescription(
|
||||||
key="soc_low",
|
key="soc_low",
|
||||||
|
@ -21,9 +21,9 @@ from .coordinator import EnphaseUpdateCoordinator
|
|||||||
from .entity import EnvoyBaseEntity
|
from .entity import EnvoyBaseEntity
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class EnvoyRelayRequiredKeysMixin:
|
class EnvoyRelaySelectEntityDescription(SelectEntityDescription):
|
||||||
"""Mixin for required keys."""
|
"""Describes an Envoy Dry Contact Relay select entity."""
|
||||||
|
|
||||||
value_fn: Callable[[EnvoyDryContactSettings], str]
|
value_fn: Callable[[EnvoyDryContactSettings], str]
|
||||||
update_fn: Callable[
|
update_fn: Callable[
|
||||||
@ -31,28 +31,14 @@ class EnvoyRelayRequiredKeysMixin:
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class EnvoyRelaySelectEntityDescription(
|
class EnvoyStorageSettingsSelectEntityDescription(SelectEntityDescription):
|
||||||
SelectEntityDescription, EnvoyRelayRequiredKeysMixin
|
"""Describes an Envoy storage settings select entity."""
|
||||||
):
|
|
||||||
"""Describes an Envoy Dry Contact Relay select entity."""
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
|
||||||
class EnvoyStorageSettingsRequiredKeysMixin:
|
|
||||||
"""Mixin for required keys."""
|
|
||||||
|
|
||||||
value_fn: Callable[[EnvoyStorageSettings], str]
|
value_fn: Callable[[EnvoyStorageSettings], str]
|
||||||
update_fn: Callable[[Envoy, str], Awaitable[dict[str, Any]]]
|
update_fn: Callable[[Envoy, str], Awaitable[dict[str, Any]]]
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
|
||||||
class EnvoyStorageSettingsSelectEntityDescription(
|
|
||||||
SelectEntityDescription, EnvoyStorageSettingsRequiredKeysMixin
|
|
||||||
):
|
|
||||||
"""Describes an Envoy storage settings select entity."""
|
|
||||||
|
|
||||||
|
|
||||||
RELAY_MODE_MAP = {
|
RELAY_MODE_MAP = {
|
||||||
DryContactMode.MANUAL: "standard",
|
DryContactMode.MANUAL: "standard",
|
||||||
DryContactMode.STATE_OF_CHARGE: "battery",
|
DryContactMode.STATE_OF_CHARGE: "battery",
|
||||||
|
@ -58,20 +58,13 @@ INVERTERS_KEY = "inverters"
|
|||||||
LAST_REPORTED_KEY = "last_reported"
|
LAST_REPORTED_KEY = "last_reported"
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class EnvoyInverterRequiredKeysMixin:
|
class EnvoyInverterSensorEntityDescription(SensorEntityDescription):
|
||||||
"""Mixin for required keys."""
|
"""Describes an Envoy inverter sensor entity."""
|
||||||
|
|
||||||
value_fn: Callable[[EnvoyInverter], datetime.datetime | float]
|
value_fn: Callable[[EnvoyInverter], datetime.datetime | float]
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
|
||||||
class EnvoyInverterSensorEntityDescription(
|
|
||||||
SensorEntityDescription, EnvoyInverterRequiredKeysMixin
|
|
||||||
):
|
|
||||||
"""Describes an Envoy inverter sensor entity."""
|
|
||||||
|
|
||||||
|
|
||||||
INVERTER_SENSORS = (
|
INVERTER_SENSORS = (
|
||||||
EnvoyInverterSensorEntityDescription(
|
EnvoyInverterSensorEntityDescription(
|
||||||
key=INVERTERS_KEY,
|
key=INVERTERS_KEY,
|
||||||
@ -91,21 +84,14 @@ INVERTER_SENSORS = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class EnvoyProductionRequiredKeysMixin:
|
class EnvoyProductionSensorEntityDescription(SensorEntityDescription):
|
||||||
"""Mixin for required keys."""
|
"""Describes an Envoy production sensor entity."""
|
||||||
|
|
||||||
value_fn: Callable[[EnvoySystemProduction], int]
|
value_fn: Callable[[EnvoySystemProduction], int]
|
||||||
on_phase: str | None
|
on_phase: str | None
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
|
||||||
class EnvoyProductionSensorEntityDescription(
|
|
||||||
SensorEntityDescription, EnvoyProductionRequiredKeysMixin
|
|
||||||
):
|
|
||||||
"""Describes an Envoy production sensor entity."""
|
|
||||||
|
|
||||||
|
|
||||||
PRODUCTION_SENSORS = (
|
PRODUCTION_SENSORS = (
|
||||||
EnvoyProductionSensorEntityDescription(
|
EnvoyProductionSensorEntityDescription(
|
||||||
key="production",
|
key="production",
|
||||||
@ -168,21 +154,14 @@ PRODUCTION_PHASE_SENSORS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class EnvoyConsumptionRequiredKeysMixin:
|
class EnvoyConsumptionSensorEntityDescription(SensorEntityDescription):
|
||||||
"""Mixin for required keys."""
|
"""Describes an Envoy consumption sensor entity."""
|
||||||
|
|
||||||
value_fn: Callable[[EnvoySystemConsumption], int]
|
value_fn: Callable[[EnvoySystemConsumption], int]
|
||||||
on_phase: str | None
|
on_phase: str | None
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
|
||||||
class EnvoyConsumptionSensorEntityDescription(
|
|
||||||
SensorEntityDescription, EnvoyConsumptionRequiredKeysMixin
|
|
||||||
):
|
|
||||||
"""Describes an Envoy consumption sensor entity."""
|
|
||||||
|
|
||||||
|
|
||||||
CONSUMPTION_SENSORS = (
|
CONSUMPTION_SENSORS = (
|
||||||
EnvoyConsumptionSensorEntityDescription(
|
EnvoyConsumptionSensorEntityDescription(
|
||||||
key="consumption",
|
key="consumption",
|
||||||
@ -245,9 +224,9 @@ CONSUMPTION_PHASE_SENSORS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class EnvoyCTRequiredKeysMixin:
|
class EnvoyCTSensorEntityDescription(SensorEntityDescription):
|
||||||
"""Mixin for required keys."""
|
"""Describes an Envoy CT sensor entity."""
|
||||||
|
|
||||||
value_fn: Callable[
|
value_fn: Callable[
|
||||||
[EnvoyMeterData],
|
[EnvoyMeterData],
|
||||||
@ -256,11 +235,6 @@ class EnvoyCTRequiredKeysMixin:
|
|||||||
on_phase: str | None
|
on_phase: str | None
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
|
||||||
class EnvoyCTSensorEntityDescription(SensorEntityDescription, EnvoyCTRequiredKeysMixin):
|
|
||||||
"""Describes an Envoy CT sensor entity."""
|
|
||||||
|
|
||||||
|
|
||||||
CT_NET_CONSUMPTION_SENSORS = (
|
CT_NET_CONSUMPTION_SENSORS = (
|
||||||
EnvoyCTSensorEntityDescription(
|
EnvoyCTSensorEntityDescription(
|
||||||
key="lifetime_net_consumption",
|
key="lifetime_net_consumption",
|
||||||
@ -390,33 +364,24 @@ CT_PRODUCTION_PHASE_SENSORS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class EnvoyEnchargeRequiredKeysMixin:
|
class EnvoyEnchargeSensorEntityDescription(SensorEntityDescription):
|
||||||
"""Mixin for required keys."""
|
"""Describes an Envoy Encharge sensor entity."""
|
||||||
|
|
||||||
value_fn: Callable[[EnvoyEncharge], datetime.datetime | int | float]
|
value_fn: Callable[[EnvoyEncharge], datetime.datetime | int | float]
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
|
||||||
class EnvoyEnchargeSensorEntityDescription(
|
|
||||||
SensorEntityDescription, EnvoyEnchargeRequiredKeysMixin
|
|
||||||
):
|
|
||||||
"""Describes an Envoy Encharge sensor entity."""
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
class EnvoyEnchargePowerRequiredKeysMixin:
|
class EnvoyEnchargePowerRequiredKeysMixin:
|
||||||
"""Mixin for required keys."""
|
"""Mixin for required keys."""
|
||||||
|
|
||||||
value_fn: Callable[[EnvoyEnchargePower], int | float]
|
|
||||||
|
|
||||||
|
@dataclass(frozen=True, kw_only=True)
|
||||||
@dataclass(frozen=True)
|
class EnvoyEnchargePowerSensorEntityDescription(SensorEntityDescription):
|
||||||
class EnvoyEnchargePowerSensorEntityDescription(
|
|
||||||
SensorEntityDescription, EnvoyEnchargePowerRequiredKeysMixin
|
|
||||||
):
|
|
||||||
"""Describes an Envoy Encharge sensor entity."""
|
"""Describes an Envoy Encharge sensor entity."""
|
||||||
|
|
||||||
|
value_fn: Callable[[EnvoyEnchargePower], int | float]
|
||||||
|
|
||||||
|
|
||||||
ENCHARGE_INVENTORY_SENSORS = (
|
ENCHARGE_INVENTORY_SENSORS = (
|
||||||
EnvoyEnchargeSensorEntityDescription(
|
EnvoyEnchargeSensorEntityDescription(
|
||||||
@ -455,20 +420,13 @@ ENCHARGE_POWER_SENSORS = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class EnvoyEnpowerRequiredKeysMixin:
|
class EnvoyEnpowerSensorEntityDescription(SensorEntityDescription):
|
||||||
"""Mixin for required keys."""
|
"""Describes an Envoy Encharge sensor entity."""
|
||||||
|
|
||||||
value_fn: Callable[[EnvoyEnpower], datetime.datetime | int | float]
|
value_fn: Callable[[EnvoyEnpower], datetime.datetime | int | float]
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
|
||||||
class EnvoyEnpowerSensorEntityDescription(
|
|
||||||
SensorEntityDescription, EnvoyEnpowerRequiredKeysMixin
|
|
||||||
):
|
|
||||||
"""Describes an Envoy Encharge sensor entity."""
|
|
||||||
|
|
||||||
|
|
||||||
ENPOWER_SENSORS = (
|
ENPOWER_SENSORS = (
|
||||||
EnvoyEnpowerSensorEntityDescription(
|
EnvoyEnpowerSensorEntityDescription(
|
||||||
key="temperature",
|
key="temperature",
|
||||||
@ -489,15 +447,13 @@ ENPOWER_SENSORS = (
|
|||||||
class EnvoyEnchargeAggregateRequiredKeysMixin:
|
class EnvoyEnchargeAggregateRequiredKeysMixin:
|
||||||
"""Mixin for required keys."""
|
"""Mixin for required keys."""
|
||||||
|
|
||||||
value_fn: Callable[[EnvoyEnchargeAggregate], int]
|
|
||||||
|
|
||||||
|
@dataclass(frozen=True, kw_only=True)
|
||||||
@dataclass(frozen=True)
|
class EnvoyEnchargeAggregateSensorEntityDescription(SensorEntityDescription):
|
||||||
class EnvoyEnchargeAggregateSensorEntityDescription(
|
|
||||||
SensorEntityDescription, EnvoyEnchargeAggregateRequiredKeysMixin
|
|
||||||
):
|
|
||||||
"""Describes an Envoy Encharge sensor entity."""
|
"""Describes an Envoy Encharge sensor entity."""
|
||||||
|
|
||||||
|
value_fn: Callable[[EnvoyEnchargeAggregate], int]
|
||||||
|
|
||||||
|
|
||||||
ENCHARGE_AGGREGATE_SENSORS = (
|
ENCHARGE_AGGREGATE_SENSORS = (
|
||||||
EnvoyEnchargeAggregateSensorEntityDescription(
|
EnvoyEnchargeAggregateSensorEntityDescription(
|
||||||
|
@ -24,54 +24,33 @@ from .entity import EnvoyBaseEntity
|
|||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class EnvoyEnpowerRequiredKeysMixin:
|
class EnvoyEnpowerSwitchEntityDescription(SwitchEntityDescription):
|
||||||
"""Mixin for required keys."""
|
"""Describes an Envoy Enpower switch entity."""
|
||||||
|
|
||||||
value_fn: Callable[[EnvoyEnpower], bool]
|
value_fn: Callable[[EnvoyEnpower], bool]
|
||||||
turn_on_fn: Callable[[Envoy], Coroutine[Any, Any, dict[str, Any]]]
|
turn_on_fn: Callable[[Envoy], Coroutine[Any, Any, dict[str, Any]]]
|
||||||
turn_off_fn: Callable[[Envoy], Coroutine[Any, Any, dict[str, Any]]]
|
turn_off_fn: Callable[[Envoy], Coroutine[Any, Any, dict[str, Any]]]
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class EnvoyEnpowerSwitchEntityDescription(
|
class EnvoyDryContactSwitchEntityDescription(SwitchEntityDescription):
|
||||||
SwitchEntityDescription, EnvoyEnpowerRequiredKeysMixin
|
"""Describes an Envoy Enpower dry contact switch entity."""
|
||||||
):
|
|
||||||
"""Describes an Envoy Enpower switch entity."""
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
|
||||||
class EnvoyDryContactRequiredKeysMixin:
|
|
||||||
"""Mixin for required keys."""
|
|
||||||
|
|
||||||
value_fn: Callable[[EnvoyDryContactStatus], bool]
|
value_fn: Callable[[EnvoyDryContactStatus], bool]
|
||||||
turn_on_fn: Callable[[Envoy, str], Coroutine[Any, Any, dict[str, Any]]]
|
turn_on_fn: Callable[[Envoy, str], Coroutine[Any, Any, dict[str, Any]]]
|
||||||
turn_off_fn: Callable[[Envoy, str], Coroutine[Any, Any, dict[str, Any]]]
|
turn_off_fn: Callable[[Envoy, str], Coroutine[Any, Any, dict[str, Any]]]
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class EnvoyDryContactSwitchEntityDescription(
|
class EnvoyStorageSettingsSwitchEntityDescription(SwitchEntityDescription):
|
||||||
SwitchEntityDescription, EnvoyDryContactRequiredKeysMixin
|
"""Describes an Envoy storage settings switch entity."""
|
||||||
):
|
|
||||||
"""Describes an Envoy Enpower dry contact switch entity."""
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
|
||||||
class EnvoyStorageSettingsRequiredKeysMixin:
|
|
||||||
"""Mixin for required keys."""
|
|
||||||
|
|
||||||
value_fn: Callable[[EnvoyStorageSettings], bool]
|
value_fn: Callable[[EnvoyStorageSettings], bool]
|
||||||
turn_on_fn: Callable[[Envoy], Awaitable[dict[str, Any]]]
|
turn_on_fn: Callable[[Envoy], Awaitable[dict[str, Any]]]
|
||||||
turn_off_fn: Callable[[Envoy], Awaitable[dict[str, Any]]]
|
turn_off_fn: Callable[[Envoy], Awaitable[dict[str, Any]]]
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
|
||||||
class EnvoyStorageSettingsSwitchEntityDescription(
|
|
||||||
SwitchEntityDescription, EnvoyStorageSettingsRequiredKeysMixin
|
|
||||||
):
|
|
||||||
"""Describes an Envoy storage settings switch entity."""
|
|
||||||
|
|
||||||
|
|
||||||
ENPOWER_GRID_SWITCH = EnvoyEnpowerSwitchEntityDescription(
|
ENPOWER_GRID_SWITCH = EnvoyEnpowerSwitchEntityDescription(
|
||||||
key="mains_admin_state",
|
key="mains_admin_state",
|
||||||
translation_key="grid_enabled",
|
translation_key="grid_enabled",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user