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