From 1a079d7c6f75fa38720f2e706e02b871246c59fd Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Wed, 15 Nov 2023 03:48:20 +0100 Subject: [PATCH] Remove LaMetric entity descriptions required fields mixins (#104001) --- homeassistant/components/lametric/button.py | 13 +++---------- homeassistant/components/lametric/number.py | 13 +++---------- homeassistant/components/lametric/select.py | 13 +++---------- homeassistant/components/lametric/sensor.py | 13 +++---------- homeassistant/components/lametric/switch.py | 16 ++++------------ 5 files changed, 16 insertions(+), 52 deletions(-) diff --git a/homeassistant/components/lametric/button.py b/homeassistant/components/lametric/button.py index 18a0c2f8f72..1de8c1d1717 100644 --- a/homeassistant/components/lametric/button.py +++ b/homeassistant/components/lametric/button.py @@ -19,20 +19,13 @@ from .entity import LaMetricEntity from .helpers import lametric_exception_handler -@dataclass -class LaMetricButtonEntityDescriptionMixin: - """Mixin values for LaMetric entities.""" +@dataclass(kw_only=True) +class LaMetricButtonEntityDescription(ButtonEntityDescription): + """Class describing LaMetric button entities.""" press_fn: Callable[[LaMetricDevice], Awaitable[Any]] -@dataclass -class LaMetricButtonEntityDescription( - ButtonEntityDescription, LaMetricButtonEntityDescriptionMixin -): - """Class describing LaMetric button entities.""" - - BUTTONS = [ LaMetricButtonEntityDescription( key="app_next", diff --git a/homeassistant/components/lametric/number.py b/homeassistant/components/lametric/number.py index da458cab61e..d8c70494264 100644 --- a/homeassistant/components/lametric/number.py +++ b/homeassistant/components/lametric/number.py @@ -19,21 +19,14 @@ from .entity import LaMetricEntity from .helpers import lametric_exception_handler -@dataclass -class LaMetricEntityDescriptionMixin: - """Mixin values for LaMetric entities.""" +@dataclass(kw_only=True) +class LaMetricNumberEntityDescription(NumberEntityDescription): + """Class describing LaMetric number entities.""" value_fn: Callable[[Device], int | None] set_value_fn: Callable[[LaMetricDevice, float], Awaitable[Any]] -@dataclass -class LaMetricNumberEntityDescription( - NumberEntityDescription, LaMetricEntityDescriptionMixin -): - """Class describing LaMetric number entities.""" - - NUMBERS = [ LaMetricNumberEntityDescription( key="brightness", diff --git a/homeassistant/components/lametric/select.py b/homeassistant/components/lametric/select.py index b7c0e55745e..f15147235ac 100644 --- a/homeassistant/components/lametric/select.py +++ b/homeassistant/components/lametric/select.py @@ -19,21 +19,14 @@ from .entity import LaMetricEntity from .helpers import lametric_exception_handler -@dataclass -class LaMetricEntityDescriptionMixin: - """Mixin values for LaMetric entities.""" +@dataclass(kw_only=True) +class LaMetricSelectEntityDescription(SelectEntityDescription): + """Class describing LaMetric select entities.""" current_fn: Callable[[Device], str] select_fn: Callable[[LaMetricDevice, str], Awaitable[Any]] -@dataclass -class LaMetricSelectEntityDescription( - SelectEntityDescription, LaMetricEntityDescriptionMixin -): - """Class describing LaMetric select entities.""" - - SELECTS = [ LaMetricSelectEntityDescription( key="brightness_mode", diff --git a/homeassistant/components/lametric/sensor.py b/homeassistant/components/lametric/sensor.py index 6cddf81b2bf..88d461e9d4f 100644 --- a/homeassistant/components/lametric/sensor.py +++ b/homeassistant/components/lametric/sensor.py @@ -21,20 +21,13 @@ from .coordinator import LaMetricDataUpdateCoordinator from .entity import LaMetricEntity -@dataclass -class LaMetricEntityDescriptionMixin: - """Mixin values for LaMetric entities.""" +@dataclass(kw_only=True) +class LaMetricSensorEntityDescription(SensorEntityDescription): + """Class describing LaMetric sensor entities.""" value_fn: Callable[[Device], int | None] -@dataclass -class LaMetricSensorEntityDescription( - SensorEntityDescription, LaMetricEntityDescriptionMixin -): - """Class describing LaMetric sensor entities.""" - - SENSORS = [ LaMetricSensorEntityDescription( key="rssi", diff --git a/homeassistant/components/lametric/switch.py b/homeassistant/components/lametric/switch.py index c33ec16d617..ace492fe0cb 100644 --- a/homeassistant/components/lametric/switch.py +++ b/homeassistant/components/lametric/switch.py @@ -19,21 +19,13 @@ from .entity import LaMetricEntity from .helpers import lametric_exception_handler -@dataclass -class LaMetricEntityDescriptionMixin: - """Mixin values for LaMetric entities.""" - - is_on_fn: Callable[[Device], bool] - set_fn: Callable[[LaMetricDevice, bool], Awaitable[Any]] - - -@dataclass -class LaMetricSwitchEntityDescription( - SwitchEntityDescription, LaMetricEntityDescriptionMixin -): +@dataclass(kw_only=True) +class LaMetricSwitchEntityDescription(SwitchEntityDescription): """Class describing LaMetric switch entities.""" available_fn: Callable[[Device], bool] = lambda device: True + is_on_fn: Callable[[Device], bool] + set_fn: Callable[[LaMetricDevice, bool], Awaitable[Any]] SWITCHES = [