Remove entity description mixin in V2C (#112960)
parent
b914ac3185
commit
4b84954d17
|
@ -21,20 +21,13 @@ from .coordinator import V2CUpdateCoordinator
|
||||||
from .entity import V2CBaseEntity
|
from .entity import V2CBaseEntity
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class V2CRequiredKeysMixin:
|
class V2CBinarySensorEntityDescription(BinarySensorEntityDescription):
|
||||||
"""Mixin for required keys."""
|
"""Describes an EVSE binary sensor entity."""
|
||||||
|
|
||||||
value_fn: Callable[[Trydan], bool]
|
value_fn: Callable[[Trydan], bool]
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
|
||||||
class V2CBinarySensorEntityDescription(
|
|
||||||
BinarySensorEntityDescription, V2CRequiredKeysMixin
|
|
||||||
):
|
|
||||||
"""Describes an EVSE binary sensor entity."""
|
|
||||||
|
|
||||||
|
|
||||||
TRYDAN_SENSORS = (
|
TRYDAN_SENSORS = (
|
||||||
V2CBinarySensorEntityDescription(
|
V2CBinarySensorEntityDescription(
|
||||||
key="connected",
|
key="connected",
|
||||||
|
|
|
@ -25,21 +25,14 @@ MIN_INTENSITY = 6
|
||||||
MAX_INTENSITY = 32
|
MAX_INTENSITY = 32
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class V2CSettingsRequiredKeysMixin:
|
class V2CSettingsNumberEntityDescription(NumberEntityDescription):
|
||||||
"""Mixin for required keys."""
|
"""Describes V2C EVSE number entity."""
|
||||||
|
|
||||||
value_fn: Callable[[TrydanData], int]
|
value_fn: Callable[[TrydanData], int]
|
||||||
update_fn: Callable[[Trydan, int], Coroutine[Any, Any, None]]
|
update_fn: Callable[[Trydan, int], Coroutine[Any, Any, None]]
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
|
||||||
class V2CSettingsNumberEntityDescription(
|
|
||||||
NumberEntityDescription, V2CSettingsRequiredKeysMixin
|
|
||||||
):
|
|
||||||
"""Describes V2C EVSE number entity."""
|
|
||||||
|
|
||||||
|
|
||||||
TRYDAN_NUMBER_SETTINGS = (
|
TRYDAN_NUMBER_SETTINGS = (
|
||||||
V2CSettingsNumberEntityDescription(
|
V2CSettingsNumberEntityDescription(
|
||||||
key="intensity",
|
key="intensity",
|
||||||
|
|
|
@ -26,18 +26,13 @@ from .entity import V2CBaseEntity
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class V2CRequiredKeysMixin:
|
class V2CSensorEntityDescription(SensorEntityDescription):
|
||||||
"""Mixin for required keys."""
|
"""Describes an EVSE Power sensor entity."""
|
||||||
|
|
||||||
value_fn: Callable[[TrydanData], float]
|
value_fn: Callable[[TrydanData], float]
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
|
||||||
class V2CSensorEntityDescription(SensorEntityDescription, V2CRequiredKeysMixin):
|
|
||||||
"""Describes an EVSE Power sensor entity."""
|
|
||||||
|
|
||||||
|
|
||||||
TRYDAN_SENSORS = (
|
TRYDAN_SENSORS = (
|
||||||
V2CSensorEntityDescription(
|
V2CSensorEntityDescription(
|
||||||
key="charge_power",
|
key="charge_power",
|
||||||
|
|
|
@ -28,20 +28,15 @@ from .entity import V2CBaseEntity
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class V2CRequiredKeysMixin:
|
class V2CSwitchEntityDescription(SwitchEntityDescription):
|
||||||
"""Mixin for required keys."""
|
"""Describes a V2C EVSE switch entity."""
|
||||||
|
|
||||||
value_fn: Callable[[TrydanData], bool]
|
value_fn: Callable[[TrydanData], bool]
|
||||||
turn_on_fn: Callable[[Trydan], Coroutine[Any, Any, Any]]
|
turn_on_fn: Callable[[Trydan], Coroutine[Any, Any, Any]]
|
||||||
turn_off_fn: Callable[[Trydan], Coroutine[Any, Any, Any]]
|
turn_off_fn: Callable[[Trydan], Coroutine[Any, Any, Any]]
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
|
||||||
class V2CSwitchEntityDescription(SwitchEntityDescription, V2CRequiredKeysMixin):
|
|
||||||
"""Describes a V2C EVSE switch entity."""
|
|
||||||
|
|
||||||
|
|
||||||
TRYDAN_SWITCHES = (
|
TRYDAN_SWITCHES = (
|
||||||
V2CSwitchEntityDescription(
|
V2CSwitchEntityDescription(
|
||||||
key="paused",
|
key="paused",
|
||||||
|
|
Loading…
Reference in New Issue