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