From 3c217d737e89e8dd4e529f835bd01b5a0733bd69 Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Mon, 11 Mar 2024 11:59:48 +0100 Subject: [PATCH] Remove entity description mixin in Roborock (#112930) --- .../components/roborock/binary_sensor.py | 13 +++---------- homeassistant/components/roborock/button.py | 13 +++---------- homeassistant/components/roborock/number.py | 13 +++---------- homeassistant/components/roborock/select.py | 15 ++++----------- homeassistant/components/roborock/sensor.py | 13 +++---------- homeassistant/components/roborock/switch.py | 13 +++---------- homeassistant/components/roborock/time.py | 11 +++-------- 7 files changed, 22 insertions(+), 69 deletions(-) diff --git a/homeassistant/components/roborock/binary_sensor.py b/homeassistant/components/roborock/binary_sensor.py index 2c903e0bcc9..00716207f7a 100644 --- a/homeassistant/components/roborock/binary_sensor.py +++ b/homeassistant/components/roborock/binary_sensor.py @@ -23,20 +23,13 @@ from .coordinator import RoborockDataUpdateCoordinator from .device import RoborockCoordinatedEntity -@dataclass(frozen=True) -class RoborockBinarySensorDescriptionMixin: - """A class that describes binary sensor entities.""" +@dataclass(frozen=True, kw_only=True) +class RoborockBinarySensorDescription(BinarySensorEntityDescription): + """A class that describes Roborock binary sensors.""" value_fn: Callable[[DeviceProp], bool | int | None] -@dataclass(frozen=True) -class RoborockBinarySensorDescription( - BinarySensorEntityDescription, RoborockBinarySensorDescriptionMixin -): - """A class that describes Roborock binary sensors.""" - - BINARY_SENSOR_DESCRIPTIONS = [ RoborockBinarySensorDescription( key="dry_status", diff --git a/homeassistant/components/roborock/button.py b/homeassistant/components/roborock/button.py index 4a37f1b3208..fe6dfabb56c 100644 --- a/homeassistant/components/roborock/button.py +++ b/homeassistant/components/roborock/button.py @@ -18,21 +18,14 @@ from .coordinator import RoborockDataUpdateCoordinator from .device import RoborockEntity -@dataclass(frozen=True) -class RoborockButtonDescriptionMixin: - """Define an entity description mixin for button entities.""" +@dataclass(frozen=True, kw_only=True) +class RoborockButtonDescription(ButtonEntityDescription): + """Describes a Roborock button entity.""" command: RoborockCommand param: list | dict | None -@dataclass(frozen=True) -class RoborockButtonDescription( - ButtonEntityDescription, RoborockButtonDescriptionMixin -): - """Describes a Roborock button entity.""" - - CONSUMABLE_BUTTON_DESCRIPTIONS = [ RoborockButtonDescription( key="reset_sensor_consumable", diff --git a/homeassistant/components/roborock/number.py b/homeassistant/components/roborock/number.py index 20f4c76fe75..09030ef8500 100644 --- a/homeassistant/components/roborock/number.py +++ b/homeassistant/components/roborock/number.py @@ -24,9 +24,9 @@ from .device import RoborockEntity _LOGGER = logging.getLogger(__name__) -@dataclass(frozen=True) -class RoborockNumberDescriptionMixin: - """Define an entity description mixin for button entities.""" +@dataclass(frozen=True, kw_only=True) +class RoborockNumberDescription(NumberEntityDescription): + """Class to describe a Roborock number entity.""" # Gets the status of the switch cache_key: CacheableAttribute @@ -34,13 +34,6 @@ class RoborockNumberDescriptionMixin: update_value: Callable[[AttributeCache, float], Coroutine[Any, Any, dict]] -@dataclass(frozen=True) -class RoborockNumberDescription( - NumberEntityDescription, RoborockNumberDescriptionMixin -): - """Class to describe an Roborock number entity.""" - - NUMBER_DESCRIPTIONS: list[RoborockNumberDescription] = [ RoborockNumberDescription( key="volume", diff --git a/homeassistant/components/roborock/select.py b/homeassistant/components/roborock/select.py index b6e55708371..fa7f4250804 100644 --- a/homeassistant/components/roborock/select.py +++ b/homeassistant/components/roborock/select.py @@ -19,9 +19,9 @@ from .coordinator import RoborockDataUpdateCoordinator from .device import RoborockCoordinatedEntity -@dataclass(frozen=True) -class RoborockSelectDescriptionMixin: - """Define an entity description mixin for select entities.""" +@dataclass(frozen=True, kw_only=True) +class RoborockSelectDescription(SelectEntityDescription): + """Class to describe a Roborock select entity.""" # The command that the select entity will send to the api. api_command: RoborockCommand @@ -29,16 +29,9 @@ class RoborockSelectDescriptionMixin: value_fn: Callable[[Status], str | None] # Gets all options of the select entity. options_lambda: Callable[[Status], list[str] | None] - # Takes the value from the select entiy and converts it for the api. + # Takes the value from the select entity and converts it for the api. parameter_lambda: Callable[[str, Status], list[int]] - -@dataclass(frozen=True) -class RoborockSelectDescription( - SelectEntityDescription, RoborockSelectDescriptionMixin -): - """Class to describe an Roborock select entity.""" - protocol_listener: RoborockDataProtocol | None = None diff --git a/homeassistant/components/roborock/sensor.py b/homeassistant/components/roborock/sensor.py index e1f87ccf603..acee1688cc7 100644 --- a/homeassistant/components/roborock/sensor.py +++ b/homeassistant/components/roborock/sensor.py @@ -37,19 +37,12 @@ from .coordinator import RoborockDataUpdateCoordinator from .device import RoborockCoordinatedEntity -@dataclass(frozen=True) -class RoborockSensorDescriptionMixin: - """A class that describes sensor entities.""" +@dataclass(frozen=True, kw_only=True) +class RoborockSensorDescription(SensorEntityDescription): + """A class that describes Roborock sensors.""" value_fn: Callable[[DeviceProp], StateType | datetime.datetime] - -@dataclass(frozen=True) -class RoborockSensorDescription( - SensorEntityDescription, RoborockSensorDescriptionMixin -): - """A class that describes Roborock sensors.""" - protocol_listener: RoborockDataProtocol | None = None diff --git a/homeassistant/components/roborock/switch.py b/homeassistant/components/roborock/switch.py index 6c9c5e18bf0..9c7ca3cdcae 100644 --- a/homeassistant/components/roborock/switch.py +++ b/homeassistant/components/roborock/switch.py @@ -25,9 +25,9 @@ from .device import RoborockEntity _LOGGER = logging.getLogger(__name__) -@dataclass(frozen=True) -class RoborockSwitchDescriptionMixin: - """Define an entity description mixin for switch entities.""" +@dataclass(frozen=True, kw_only=True) +class RoborockSwitchDescription(SwitchEntityDescription): + """Class to describe a Roborock switch entity.""" # Gets the status of the switch cache_key: CacheableAttribute @@ -37,13 +37,6 @@ class RoborockSwitchDescriptionMixin: attribute: str -@dataclass(frozen=True) -class RoborockSwitchDescription( - SwitchEntityDescription, RoborockSwitchDescriptionMixin -): - """Class to describe an Roborock switch entity.""" - - SWITCH_DESCRIPTIONS: list[RoborockSwitchDescription] = [ RoborockSwitchDescription( cache_key=CacheableAttribute.child_lock_status, diff --git a/homeassistant/components/roborock/time.py b/homeassistant/components/roborock/time.py index e142713213c..9a3cac86425 100644 --- a/homeassistant/components/roborock/time.py +++ b/homeassistant/components/roborock/time.py @@ -26,9 +26,9 @@ from .device import RoborockEntity _LOGGER = logging.getLogger(__name__) -@dataclass(frozen=True) -class RoborockTimeDescriptionMixin: - """Define an entity description mixin for time entities.""" +@dataclass(frozen=True, kw_only=True) +class RoborockTimeDescription(TimeEntityDescription): + """Class to describe a Roborock time entity.""" # Gets the status of the switch cache_key: CacheableAttribute @@ -38,11 +38,6 @@ class RoborockTimeDescriptionMixin: get_value: Callable[[AttributeCache], datetime.time] -@dataclass(frozen=True) -class RoborockTimeDescription(TimeEntityDescription, RoborockTimeDescriptionMixin): - """Class to describe an Roborock time entity.""" - - TIME_DESCRIPTIONS: list[RoborockTimeDescription] = [ RoborockTimeDescription( key="dnd_start_time",