Skip to content

Commit 5f0d04c

Browse files
committed
Drop scene_num property to gain stability (Closes: #617)
1 parent 43d9eaf commit 5f0d04c

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

miio/philips_eyecare.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import logging
22
from collections import defaultdict
3-
from typing import Any, Dict
3+
from typing import Any, Dict, Optional
44

55
import click
66

@@ -60,9 +60,11 @@ def eyecare(self) -> bool:
6060
return self.data["eyecare"] == "on"
6161

6262
@property
63-
def scene(self) -> int:
63+
def scene(self) -> Optional[int]:
6464
"""Current fixed scene."""
65-
return self.data["scene_num"]
65+
if "scene_num" in self.data and self.data["scene_num"] is not None:
66+
return self.data["scene_num"]
67+
return None
6668

6769
@property
6870
def smart_night_light(self) -> bool:
@@ -97,13 +99,12 @@ def status(self) -> PhilipsEyecareStatus:
9799
properties = [
98100
"power",
99101
"bright",
100-
"notifystatus",
101102
"ambstatus",
103+
"notifystatus",
102104
"ambvalue",
105+
"dvalue",
103106
"eyecare",
104-
"scene_num",
105107
"bls",
106-
"dvalue",
107108
]
108109
values = self.get_properties(properties)
109110

miio/tests/test_philips_eyecare.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ def __init__(self, *args, **kwargs):
1717
"ambstatus": "off",
1818
"ambvalue": 100,
1919
"eyecare": "on",
20-
"scene_num": 3,
2120
"bls": "on",
2221
"dvalue": 0,
2322
}
@@ -77,7 +76,6 @@ def test_status(self):
7776
assert self.state().ambient is (self.device.start_state["ambstatus"] == "on")
7877
assert self.state().ambient_brightness == self.device.start_state["ambvalue"]
7978
assert self.state().eyecare is (self.device.start_state["eyecare"] == "on")
80-
assert self.state().scene == self.device.start_state["scene_num"]
8179
assert self.state().smart_night_light is (
8280
self.device.start_state["bls"] == "on"
8381
)
@@ -112,13 +110,8 @@ def brightness():
112110
self.device.set_brightness(101)
113111

114112
def test_set_scene(self):
115-
def scene():
116-
return self.device.status().scene
117-
118113
self.device.set_scene(1)
119-
assert scene() == 1
120114
self.device.set_scene(2)
121-
assert scene() == 2
122115

123116
with pytest.raises(PhilipsEyecareException):
124117
self.device.set_scene(-1)

0 commit comments

Comments
 (0)