Skip to content

Commit

Permalink
Handle wake-up scenes (#71)
Browse files Browse the repository at this point in the history
* Handle wake-up scenes

* Add controller attribute 'switchLabel'

* Document 'relation_id'
  • Loading branch information
bjorncs authored Apr 20, 2024
1 parent dd60008 commit b37b9b5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ All available devices (Light, Controller, Outlet, ...) consist of the core data

```python
id: str
relation_id: Optional[str] = None
type: str
device_type: str
created_at: datetime.datetime
Expand Down Expand Up @@ -261,6 +262,7 @@ The controller object has the following attributes (additional to the core attri
```python
is_on: bool
battery_percentage: Optional[int] = None
switch_label: Optional[str] = None
```
Available methods for controller are:
Expand Down
1 change: 1 addition & 0 deletions src/dirigera/devices/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
class ControllerAttributes(Attributes):
is_on: bool
battery_percentage: Optional[int] = None
switch_label: Optional[str] = None


class Controller(Device):
Expand Down
1 change: 1 addition & 0 deletions src/dirigera/devices/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class SceneType(Enum):
USER_SCENE = "userScene"
CUSTOM_SCENE = "customScene"
PLAYLIST_SCENE = "playlistScene"
WAKEUP_SCENE = "wakeUpScene"


class Scene(BaseIkeaModel):
Expand Down
8 changes: 8 additions & 0 deletions tests/test_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ def test_dict_to_controller(fake_client: FakeDirigeraHub) -> None:

controller = dict_to_controller(somrig_button_1, fake_client)
assert controller.relation_id == somrig_button_1["relationId"]
assert (
controller.attributes.switch_label
== somrig_button_1["attributes"]["switchLabel"]
)

somrig_button_2: Dict[str, Any] = {
"id": "1111aaaa-1111-1111-aa11-1a1aa1a111a1_2",
Expand Down Expand Up @@ -210,3 +214,7 @@ def test_dict_to_controller(fake_client: FakeDirigeraHub) -> None:

controller = dict_to_controller(somrig_button_2, fake_client)
assert controller.relation_id == somrig_button_2["relationId"]
assert (
controller.attributes.switch_label
== somrig_button_2["attributes"]["switchLabel"]
)

0 comments on commit b37b9b5

Please sign in to comment.