Remove entity description mixin in Devolo Home Network (#112399)

* Remove entity description mixin in Devolo Home Network

* Fix
This commit is contained in:
Joost Lekkerkerker 2024-03-05 21:08:57 +01:00 committed by GitHub
parent 32bb33c55e
commit 9a24e97ecb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 19 additions and 59 deletions

View File

@ -32,20 +32,13 @@ def _is_connected_to_router(entity: DevoloBinarySensorEntity) -> bool:
) )
@dataclass(frozen=True) @dataclass(frozen=True, kw_only=True)
class DevoloBinarySensorRequiredKeysMixin: class DevoloBinarySensorEntityDescription(BinarySensorEntityDescription):
"""Mixin for required keys.""" """Describes devolo sensor entity."""
value_func: Callable[[DevoloBinarySensorEntity], bool] value_func: Callable[[DevoloBinarySensorEntity], bool]
@dataclass(frozen=True)
class DevoloBinarySensorEntityDescription(
BinarySensorEntityDescription, DevoloBinarySensorRequiredKeysMixin
):
"""Describes devolo sensor entity."""
SENSOR_TYPES: dict[str, DevoloBinarySensorEntityDescription] = { SENSOR_TYPES: dict[str, DevoloBinarySensorEntityDescription] = {
CONNECTED_TO_ROUTER: DevoloBinarySensorEntityDescription( CONNECTED_TO_ROUTER: DevoloBinarySensorEntityDescription(
key=CONNECTED_TO_ROUTER, key=CONNECTED_TO_ROUTER,

View File

@ -22,20 +22,13 @@ from .const import DOMAIN, IDENTIFY, PAIRING, RESTART, START_WPS
from .entity import DevoloEntity from .entity import DevoloEntity
@dataclass(frozen=True) @dataclass(frozen=True, kw_only=True)
class DevoloButtonRequiredKeysMixin: class DevoloButtonEntityDescription(ButtonEntityDescription):
"""Mixin for required keys.""" """Describes devolo button entity."""
press_func: Callable[[Device], Awaitable[bool]] press_func: Callable[[Device], Awaitable[bool]]
@dataclass(frozen=True)
class DevoloButtonEntityDescription(
ButtonEntityDescription, DevoloButtonRequiredKeysMixin
):
"""Describes devolo button entity."""
BUTTON_TYPES: dict[str, DevoloButtonEntityDescription] = { BUTTON_TYPES: dict[str, DevoloButtonEntityDescription] = {
IDENTIFY: DevoloButtonEntityDescription( IDENTIFY: DevoloButtonEntityDescription(
key=IDENTIFY, key=IDENTIFY,

View File

@ -21,20 +21,13 @@ from .const import DOMAIN, IMAGE_GUEST_WIFI, SWITCH_GUEST_WIFI
from .entity import DevoloCoordinatorEntity from .entity import DevoloCoordinatorEntity
@dataclass(frozen=True) @dataclass(frozen=True, kw_only=True)
class DevoloImageRequiredKeysMixin: class DevoloImageEntityDescription(ImageEntityDescription):
"""Mixin for required keys.""" """Describes devolo image entity."""
image_func: Callable[[WifiGuestAccessGet], bytes] image_func: Callable[[WifiGuestAccessGet], bytes]
@dataclass(frozen=True)
class DevoloImageEntityDescription(
ImageEntityDescription, DevoloImageRequiredKeysMixin
):
"""Describes devolo image entity."""
IMAGE_TYPES: dict[str, DevoloImageEntityDescription] = { IMAGE_TYPES: dict[str, DevoloImageEntityDescription] = {
IMAGE_GUEST_WIFI: DevoloImageEntityDescription( IMAGE_GUEST_WIFI: DevoloImageEntityDescription(
key=IMAGE_GUEST_WIFI, key=IMAGE_GUEST_WIFI,

View File

@ -49,19 +49,14 @@ class DataRateDirection(StrEnum):
TX = "tx_rate" TX = "tx_rate"
@dataclass(frozen=True) @dataclass(frozen=True, kw_only=True)
class DevoloSensorRequiredKeysMixin(Generic[_CoordinatorDataT]):
"""Mixin for required keys."""
value_func: Callable[[_CoordinatorDataT], float]
@dataclass(frozen=True)
class DevoloSensorEntityDescription( class DevoloSensorEntityDescription(
SensorEntityDescription, DevoloSensorRequiredKeysMixin[_CoordinatorDataT] SensorEntityDescription, Generic[_CoordinatorDataT]
): ):
"""Describes devolo sensor entity.""" """Describes devolo sensor entity."""
value_func: Callable[[_CoordinatorDataT], float]
SENSOR_TYPES: dict[str, DevoloSensorEntityDescription[Any]] = { SENSOR_TYPES: dict[str, DevoloSensorEntityDescription[Any]] = {
CONNECTED_PLC_DEVICES: DevoloSensorEntityDescription[LogicalNetwork]( CONNECTED_PLC_DEVICES: DevoloSensorEntityDescription[LogicalNetwork](

View File

@ -23,22 +23,15 @@ from .entity import DevoloCoordinatorEntity
_DataT = TypeVar("_DataT", bound=WifiGuestAccessGet | bool) _DataT = TypeVar("_DataT", bound=WifiGuestAccessGet | bool)
@dataclass(frozen=True) @dataclass(frozen=True, kw_only=True)
class DevoloSwitchRequiredKeysMixin(Generic[_DataT]): class DevoloSwitchEntityDescription(SwitchEntityDescription, Generic[_DataT]):
"""Mixin for required keys.""" """Describes devolo switch entity."""
is_on_func: Callable[[_DataT], bool] is_on_func: Callable[[_DataT], bool]
turn_on_func: Callable[[Device], Awaitable[bool]] turn_on_func: Callable[[Device], Awaitable[bool]]
turn_off_func: Callable[[Device], Awaitable[bool]] turn_off_func: Callable[[Device], Awaitable[bool]]
@dataclass(frozen=True)
class DevoloSwitchEntityDescription(
SwitchEntityDescription, DevoloSwitchRequiredKeysMixin[_DataT]
):
"""Describes devolo switch entity."""
SWITCH_TYPES: dict[str, DevoloSwitchEntityDescription[Any]] = { SWITCH_TYPES: dict[str, DevoloSwitchEntityDescription[Any]] = {
SWITCH_GUEST_WIFI: DevoloSwitchEntityDescription[WifiGuestAccessGet]( SWITCH_GUEST_WIFI: DevoloSwitchEntityDescription[WifiGuestAccessGet](
key=SWITCH_GUEST_WIFI, key=SWITCH_GUEST_WIFI,

View File

@ -26,21 +26,14 @@ from .const import DOMAIN, REGULAR_FIRMWARE
from .entity import DevoloCoordinatorEntity from .entity import DevoloCoordinatorEntity
@dataclass(frozen=True) @dataclass(frozen=True, kw_only=True)
class DevoloUpdateRequiredKeysMixin: class DevoloUpdateEntityDescription(UpdateEntityDescription):
"""Mixin for required keys.""" """Describes devolo update entity."""
latest_version: Callable[[UpdateFirmwareCheck], str] latest_version: Callable[[UpdateFirmwareCheck], str]
update_func: Callable[[Device], Awaitable[bool]] update_func: Callable[[Device], Awaitable[bool]]
@dataclass(frozen=True)
class DevoloUpdateEntityDescription(
UpdateEntityDescription, DevoloUpdateRequiredKeysMixin
):
"""Describes devolo update entity."""
UPDATE_TYPES: dict[str, DevoloUpdateEntityDescription] = { UPDATE_TYPES: dict[str, DevoloUpdateEntityDescription] = {
REGULAR_FIRMWARE: DevoloUpdateEntityDescription( REGULAR_FIRMWARE: DevoloUpdateEntityDescription(
key=REGULAR_FIRMWARE, key=REGULAR_FIRMWARE,