mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Remove entity description mixin in Shelly (#112938)
* Remove entity description mixin in Shelly * fix * Fix
This commit is contained in:
parent
9a647d9b17
commit
b125a6b1bb
@ -39,19 +39,19 @@ from .utils import (
|
||||
)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class BlockBinarySensorDescription(
|
||||
BlockEntityDescription, BinarySensorEntityDescription
|
||||
):
|
||||
"""Class to describe a BLOCK binary sensor."""
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class RpcBinarySensorDescription(RpcEntityDescription, BinarySensorEntityDescription):
|
||||
"""Class to describe a RPC binary sensor."""
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class RestBinarySensorDescription(RestEntityDescription, BinarySensorEntityDescription):
|
||||
"""Class to describe a REST binary sensor."""
|
||||
|
||||
|
@ -32,19 +32,12 @@ _ShellyCoordinatorT = TypeVar(
|
||||
)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class ShellyButtonDescriptionMixin(Generic[_ShellyCoordinatorT]):
|
||||
"""Mixin to describe a Button entity."""
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class ShellyButtonDescription(ButtonEntityDescription, Generic[_ShellyCoordinatorT]):
|
||||
"""Class to describe a Button entity."""
|
||||
|
||||
press_action: Callable[[_ShellyCoordinatorT], Coroutine[Any, Any, None]]
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class ShellyButtonDescription(
|
||||
ButtonEntityDescription, ShellyButtonDescriptionMixin[_ShellyCoordinatorT]
|
||||
):
|
||||
"""Class to describe a Button entity."""
|
||||
|
||||
supported: Callable[[_ShellyCoordinatorT], bool] = lambda _: True
|
||||
|
||||
|
||||
|
@ -279,21 +279,16 @@ class BlockEntityDescription(EntityDescription):
|
||||
extra_state_attributes: Callable[[Block], dict | None] | None = None
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class RpcEntityRequiredKeysMixin:
|
||||
"""Class for RPC entity required keys."""
|
||||
|
||||
sub_key: str
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class RpcEntityDescription(EntityDescription, RpcEntityRequiredKeysMixin):
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class RpcEntityDescription(EntityDescription):
|
||||
"""Class to describe a RPC entity."""
|
||||
|
||||
# BlockEntity does not support UNDEFINED or None,
|
||||
# restrict the type to str.
|
||||
name: str = ""
|
||||
|
||||
sub_key: str
|
||||
|
||||
value: Callable[[Any, Any], Any] | None = None
|
||||
available: Callable[[dict], bool] | None = None
|
||||
removal_condition: Callable[[dict, dict, str], bool] | None = None
|
||||
|
@ -38,14 +38,14 @@ from .utils import (
|
||||
)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class ShellyBlockEventDescription(EventEntityDescription):
|
||||
"""Class to describe Shelly event."""
|
||||
|
||||
removal_condition: Callable[[dict, Block], bool] | None = None
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class ShellyRpcEventDescription(EventEntityDescription):
|
||||
"""Class to describe Shelly event."""
|
||||
|
||||
|
@ -30,7 +30,7 @@ from .entity import (
|
||||
)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class BlockNumberDescription(BlockEntityDescription, NumberEntityDescription):
|
||||
"""Class to describe a BLOCK sensor."""
|
||||
|
||||
|
@ -59,17 +59,17 @@ from .utils import (
|
||||
)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class BlockSensorDescription(BlockEntityDescription, SensorEntityDescription):
|
||||
"""Class to describe a BLOCK sensor."""
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class RpcSensorDescription(RpcEntityDescription, SensorEntityDescription):
|
||||
"""Class to describe a RPC sensor."""
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class RestSensorDescription(RestEntityDescription, SensorEntityDescription):
|
||||
"""Class to describe a REST sensor."""
|
||||
|
||||
|
@ -46,7 +46,7 @@ from .utils import (
|
||||
)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class BlockSwitchDescription(BlockEntityDescription, SwitchEntityDescription):
|
||||
"""Class to describe a BLOCK switch."""
|
||||
|
||||
|
@ -41,35 +41,21 @@ from .utils import get_device_entry_gen, get_release_url
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class RpcUpdateRequiredKeysMixin:
|
||||
"""Class for RPC update required keys."""
|
||||
|
||||
latest_version: Callable[[dict], Any]
|
||||
beta: bool
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class RestUpdateRequiredKeysMixin:
|
||||
"""Class for REST update required keys."""
|
||||
|
||||
latest_version: Callable[[dict], Any]
|
||||
beta: bool
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class RpcUpdateDescription(
|
||||
RpcEntityDescription, UpdateEntityDescription, RpcUpdateRequiredKeysMixin
|
||||
):
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class RpcUpdateDescription(RpcEntityDescription, UpdateEntityDescription):
|
||||
"""Class to describe a RPC update."""
|
||||
|
||||
latest_version: Callable[[dict], Any]
|
||||
beta: bool
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class RestUpdateDescription(
|
||||
RestEntityDescription, UpdateEntityDescription, RestUpdateRequiredKeysMixin
|
||||
):
|
||||
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class RestUpdateDescription(RestEntityDescription, UpdateEntityDescription):
|
||||
"""Class to describe a REST update."""
|
||||
|
||||
latest_version: Callable[[dict], Any]
|
||||
beta: bool
|
||||
|
||||
|
||||
REST_UPDATES: Final = {
|
||||
"fwupdate": RestUpdateDescription(
|
||||
|
Loading…
x
Reference in New Issue
Block a user