Remove LaMetric entity descriptions required fields mixins (#104001)

pull/104014/head
Franck Nijhof 2023-11-15 03:48:20 +01:00 committed by GitHub
parent ce1e6ce006
commit 1a079d7c6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 52 deletions

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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 = [