diff --git a/homeassistant/components/shelly/binary_sensor.py b/homeassistant/components/shelly/binary_sensor.py index bce84a829ed..f2d1fe15bbe 100644 --- a/homeassistant/components/shelly/binary_sensor.py +++ b/homeassistant/components/shelly/binary_sensor.py @@ -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.""" diff --git a/homeassistant/components/shelly/button.py b/homeassistant/components/shelly/button.py index 1c497231b3e..12c347908fb 100644 --- a/homeassistant/components/shelly/button.py +++ b/homeassistant/components/shelly/button.py @@ -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 diff --git a/homeassistant/components/shelly/entity.py b/homeassistant/components/shelly/entity.py index 6cb4c7f6542..d5202713405 100644 --- a/homeassistant/components/shelly/entity.py +++ b/homeassistant/components/shelly/entity.py @@ -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 diff --git a/homeassistant/components/shelly/event.py b/homeassistant/components/shelly/event.py index ea7cac2d253..0b6b81461ac 100644 --- a/homeassistant/components/shelly/event.py +++ b/homeassistant/components/shelly/event.py @@ -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.""" diff --git a/homeassistant/components/shelly/number.py b/homeassistant/components/shelly/number.py index 3dd2550b6ff..1b1c9c42a11 100644 --- a/homeassistant/components/shelly/number.py +++ b/homeassistant/components/shelly/number.py @@ -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.""" diff --git a/homeassistant/components/shelly/sensor.py b/homeassistant/components/shelly/sensor.py index 3dc9102df70..ec5f31dae8a 100644 --- a/homeassistant/components/shelly/sensor.py +++ b/homeassistant/components/shelly/sensor.py @@ -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.""" diff --git a/homeassistant/components/shelly/switch.py b/homeassistant/components/shelly/switch.py index b690cfab6c8..48ff337d22a 100644 --- a/homeassistant/components/shelly/switch.py +++ b/homeassistant/components/shelly/switch.py @@ -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.""" diff --git a/homeassistant/components/shelly/update.py b/homeassistant/components/shelly/update.py index 765e4ee441b..414bb4d6258 100644 --- a/homeassistant/components/shelly/update.py +++ b/homeassistant/components/shelly/update.py @@ -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(