Skip to content

Commit

Permalink
Remove entity description mixin in Sensibo (home-assistant#112936)
Browse files Browse the repository at this point in the history
  • Loading branch information
joostlek authored Mar 10, 2024
1 parent 5f4881c commit 049f0f5
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 90 deletions.
26 changes: 6 additions & 20 deletions homeassistant/components/sensibo/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,18 @@
PARALLEL_UPDATES = 0


@dataclass(frozen=True)
class MotionBaseEntityDescriptionMixin:
"""Mixin for required Sensibo base description keys."""
@dataclass(frozen=True, kw_only=True)
class SensiboMotionBinarySensorEntityDescription(BinarySensorEntityDescription):
"""Describes Sensibo Motion sensor entity."""

value_fn: Callable[[MotionSensor], bool | None]


@dataclass(frozen=True)
class DeviceBaseEntityDescriptionMixin:
"""Mixin for required Sensibo base description keys."""

value_fn: Callable[[SensiboDevice], bool | None]


@dataclass(frozen=True)
class SensiboMotionBinarySensorEntityDescription(
BinarySensorEntityDescription, MotionBaseEntityDescriptionMixin
):
@dataclass(frozen=True, kw_only=True)
class SensiboDeviceBinarySensorEntityDescription(BinarySensorEntityDescription):
"""Describes Sensibo Motion sensor entity."""


@dataclass(frozen=True)
class SensiboDeviceBinarySensorEntityDescription(
BinarySensorEntityDescription, DeviceBaseEntityDescriptionMixin
):
"""Describes Sensibo Motion sensor entity."""
value_fn: Callable[[SensiboDevice], bool | None]


FILTER_CLEAN_REQUIRED_DESCRIPTION = SensiboDeviceBinarySensorEntityDescription(
Expand Down
13 changes: 3 additions & 10 deletions homeassistant/components/sensibo/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,13 @@
PARALLEL_UPDATES = 0


@dataclass(frozen=True)
class SensiboEntityDescriptionMixin:
"""Mixin values for Sensibo entities."""
@dataclass(frozen=True, kw_only=True)
class SensiboButtonEntityDescription(ButtonEntityDescription):
"""Class describing Sensibo Button entities."""

data_key: str


@dataclass(frozen=True)
class SensiboButtonEntityDescription(
ButtonEntityDescription, SensiboEntityDescriptionMixin
):
"""Class describing Sensibo Button entities."""


DEVICE_BUTTON_TYPES = SensiboButtonEntityDescription(
key="reset_filter",
translation_key="reset_filter",
Expand Down
13 changes: 3 additions & 10 deletions homeassistant/components/sensibo/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,14 @@
PARALLEL_UPDATES = 0


@dataclass(frozen=True)
class SensiboEntityDescriptionMixin:
"""Mixin values for Sensibo entities."""
@dataclass(frozen=True, kw_only=True)
class SensiboNumberEntityDescription(NumberEntityDescription):
"""Class describing Sensibo Number entities."""

remote_key: str
value_fn: Callable[[SensiboDevice], float | None]


@dataclass(frozen=True)
class SensiboNumberEntityDescription(
NumberEntityDescription, SensiboEntityDescriptionMixin
):
"""Class describing Sensibo Number entities."""


DEVICE_NUMBER_TYPES = (
SensiboNumberEntityDescription(
key="calibration_temp",
Expand Down
13 changes: 3 additions & 10 deletions homeassistant/components/sensibo/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,16 @@
PARALLEL_UPDATES = 0


@dataclass(frozen=True)
class SensiboSelectDescriptionMixin:
"""Mixin values for Sensibo entities."""
@dataclass(frozen=True, kw_only=True)
class SensiboSelectEntityDescription(SelectEntityDescription):
"""Class describing Sensibo Select entities."""

data_key: str
value_fn: Callable[[SensiboDevice], str | None]
options_fn: Callable[[SensiboDevice], list[str] | None]
transformation: Callable[[SensiboDevice], dict | None]


@dataclass(frozen=True)
class SensiboSelectEntityDescription(
SelectEntityDescription, SensiboSelectDescriptionMixin
):
"""Class describing Sensibo Select entities."""


DEVICE_SELECT_TYPES = (
SensiboSelectEntityDescription(
key="horizontalSwing",
Expand Down
26 changes: 6 additions & 20 deletions homeassistant/components/sensibo/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,35 +37,21 @@
PARALLEL_UPDATES = 0


@dataclass(frozen=True)
class MotionBaseEntityDescriptionMixin:
"""Mixin for required Sensibo base description keys."""
@dataclass(frozen=True, kw_only=True)
class SensiboMotionSensorEntityDescription(SensorEntityDescription):
"""Describes Sensibo Motion sensor entity."""

value_fn: Callable[[MotionSensor], StateType]


@dataclass(frozen=True)
class DeviceBaseEntityDescriptionMixin:
"""Mixin for required Sensibo base description keys."""
@dataclass(frozen=True, kw_only=True)
class SensiboDeviceSensorEntityDescription(SensorEntityDescription):
"""Describes Sensibo Device sensor entity."""

value_fn: Callable[[SensiboDevice], StateType | datetime]
extra_fn: Callable[[SensiboDevice], dict[str, str | bool | None] | None] | None


@dataclass(frozen=True)
class SensiboMotionSensorEntityDescription(
SensorEntityDescription, MotionBaseEntityDescriptionMixin
):
"""Describes Sensibo Motion sensor entity."""


@dataclass(frozen=True)
class SensiboDeviceSensorEntityDescription(
SensorEntityDescription, DeviceBaseEntityDescriptionMixin
):
"""Describes Sensibo Device sensor entity."""


FILTER_LAST_RESET_DESCRIPTION = SensiboDeviceSensorEntityDescription(
key="filter_last_reset",
translation_key="filter_last_reset",
Expand Down
13 changes: 3 additions & 10 deletions homeassistant/components/sensibo/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
PARALLEL_UPDATES = 0


@dataclass(frozen=True)
class DeviceBaseEntityDescriptionMixin:
"""Mixin for required Sensibo Device description keys."""
@dataclass(frozen=True, kw_only=True)
class SensiboDeviceSwitchEntityDescription(SwitchEntityDescription):
"""Describes Sensibo Switch entity."""

value_fn: Callable[[SensiboDevice], bool | None]
extra_fn: Callable[[SensiboDevice], dict[str, str | bool | None]] | None
Expand All @@ -36,13 +36,6 @@ class DeviceBaseEntityDescriptionMixin:
data_key: str


@dataclass(frozen=True)
class SensiboDeviceSwitchEntityDescription(
SwitchEntityDescription, DeviceBaseEntityDescriptionMixin
):
"""Describes Sensibo Switch entity."""


DEVICE_SWITCH_TYPES: tuple[SensiboDeviceSwitchEntityDescription, ...] = (
SensiboDeviceSwitchEntityDescription(
key="timer_on_switch",
Expand Down
13 changes: 3 additions & 10 deletions homeassistant/components/sensibo/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,14 @@
PARALLEL_UPDATES = 0


@dataclass(frozen=True)
class DeviceBaseEntityDescriptionMixin:
"""Mixin for required Sensibo base description keys."""
@dataclass(frozen=True, kw_only=True)
class SensiboDeviceUpdateEntityDescription(UpdateEntityDescription):
"""Describes Sensibo Update entity."""

value_version: Callable[[SensiboDevice], str | None]
value_available: Callable[[SensiboDevice], str | None]


@dataclass(frozen=True)
class SensiboDeviceUpdateEntityDescription(
UpdateEntityDescription, DeviceBaseEntityDescriptionMixin
):
"""Describes Sensibo Update entity."""


DEVICE_SENSOR_TYPES: tuple[SensiboDeviceUpdateEntityDescription, ...] = (
SensiboDeviceUpdateEntityDescription(
key="fw_ver_available",
Expand Down

0 comments on commit 049f0f5

Please sign in to comment.