|
3 | 3 | from dataclasses import dataclass
|
4 | 4 | from typing import Any
|
5 | 5 |
|
6 |
| -from pysmarlaapi import Federwiege |
7 | 6 | from pysmarlaapi.federwiege.classes import Property
|
8 | 7 |
|
9 | 8 | from homeassistant.components.switch import SwitchEntity, SwitchEntityDescription
|
10 | 9 | from homeassistant.core import HomeAssistant
|
11 | 10 | from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
12 | 11 |
|
13 | 12 | from . import FederwiegeConfigEntry
|
14 |
| -from .entity import SmarlaBaseEntity |
| 13 | +from .entity import SmarlaBaseEntity, SmarlaEntityDescription |
15 | 14 |
|
16 | 15 |
|
17 | 16 | @dataclass(frozen=True, kw_only=True)
|
18 |
| -class SmarlaSwitchEntityDescription(SwitchEntityDescription): |
| 17 | +class SmarlaSwitchEntityDescription(SmarlaEntityDescription, SwitchEntityDescription): |
19 | 18 | """Class describing Swing2Sleep Smarla switch entity."""
|
20 | 19 |
|
21 |
| - service: str |
22 |
| - property: str |
23 |
| - |
24 | 20 |
|
25 | 21 | SWITCHES: list[SmarlaSwitchEntityDescription] = [
|
26 | 22 | SmarlaSwitchEntityDescription(
|
@@ -55,17 +51,6 @@ class SmarlaSwitch(SmarlaBaseEntity, SwitchEntity):
|
55 | 51 |
|
56 | 52 | _property: Property[bool]
|
57 | 53 |
|
58 |
| - def __init__( |
59 |
| - self, |
60 |
| - federwiege: Federwiege, |
61 |
| - desc: SmarlaSwitchEntityDescription, |
62 |
| - ) -> None: |
63 |
| - """Initialize a Smarla switch.""" |
64 |
| - prop = federwiege.get_property(desc.service, desc.property) |
65 |
| - super().__init__(federwiege, prop) |
66 |
| - self.entity_description = desc |
67 |
| - self._attr_unique_id = f"{federwiege.serial_number}-{desc.key}" |
68 |
| - |
69 | 54 | @property
|
70 | 55 | def is_on(self) -> bool:
|
71 | 56 | """Return the entity value to represent the entity state."""
|
|
0 commit comments