Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop scene_num property to gain stability (Closes: #617) #1147

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions miio/philips_eyecare.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
from collections import defaultdict
from typing import Any, Dict
from typing import Any, Dict, Optional

import click

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

@property
def scene(self) -> int:
def scene(self) -> Optional[int]:
"""Current fixed scene."""
return self.data["scene_num"]
if "scene_num" in self.data and self.data["scene_num"] is not None:
return self.data["scene_num"]
return None

@property
def smart_night_light(self) -> bool:
Expand Down Expand Up @@ -97,13 +99,12 @@ def status(self) -> PhilipsEyecareStatus:
properties = [
"power",
"bright",
"notifystatus",
"ambstatus",
"notifystatus",
"ambvalue",
"dvalue",
"eyecare",
"scene_num",
"bls",
"dvalue",
]
values = self.get_properties(properties)

Expand Down
7 changes: 0 additions & 7 deletions miio/tests/test_philips_eyecare.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def __init__(self, *args, **kwargs):
"ambstatus": "off",
"ambvalue": 100,
"eyecare": "on",
"scene_num": 3,
"bls": "on",
"dvalue": 0,
}
Expand Down Expand Up @@ -77,7 +76,6 @@ def test_status(self):
assert self.state().ambient is (self.device.start_state["ambstatus"] == "on")
assert self.state().ambient_brightness == self.device.start_state["ambvalue"]
assert self.state().eyecare is (self.device.start_state["eyecare"] == "on")
assert self.state().scene == self.device.start_state["scene_num"]
assert self.state().smart_night_light is (
self.device.start_state["bls"] == "on"
)
Expand Down Expand Up @@ -112,13 +110,8 @@ def brightness():
self.device.set_brightness(101)

def test_set_scene(self):
def scene():
return self.device.status().scene

self.device.set_scene(1)
assert scene() == 1
self.device.set_scene(2)
assert scene() == 2

with pytest.raises(PhilipsEyecareException):
self.device.set_scene(-1)
Expand Down