Skip to content

Commit

Permalink
Order of classes interchanged.
Browse files Browse the repository at this point in the history
  • Loading branch information
syssi committed Oct 21, 2017
1 parent 8ac171b commit 02307e5
Showing 1 changed file with 61 additions and 61 deletions.
122 changes: 61 additions & 61 deletions miio/philips_eyecare.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,67 @@
_LOGGER = logging.getLogger(__name__)


class PhilipsEyecareStatus:
"""Container for status reports from Xiaomi Philips Eyecare Smart Lamp 2"""

def __init__(self, data: Dict[str, Any]) -> None:
# ['power': 'off', 'bright': 5, 'notifystatus': 'off',
# 'ambstatus': 'off': 'ambvalue': 41, 'eyecare': 'on',
# 'scene_num': 3, 'bls': 'on', 'dvalue': 0]
self.data = data

@property
def power(self) -> str:
return self.data["power"]

@property
def is_on(self) -> bool:
return self.power == "on"

@property
def brightness(self) -> int:
return self.data["bright"]

@property
def reminder(self) -> bool:
return self.data["notifystatus"] == "on"

@property
def ambient(self) -> bool:
return self.data["ambstatus"] == "on"

@property
def ambient_brightness(self) -> int:
return self.data["ambvalue"]

@property
def eyecare(self) -> bool:
return self.data["eyecare"] == "on"

@property
def scene(self) -> int:
return self.data["scene_num"]

@property
def smart_night_light(self) -> bool:
return self.data["bls"] == "on"

@property
def delay_off_countdown(self) -> int:
return self.data["dvalue"]

def __str__(self) -> str:
s = "<PhilipsEyecareStatus power=%s, brightness=%s, " \
"notify=%s, ambient=%s, ambient_brightness=%s, " \
"eyecare=%s, scene=%s, smart_night_light=%s, " \
"delay_off_countdown=%s>" % \
(self.power, self.brightness,
self.reminder, self.ambient, self.ambient_brightness,
self.eyecare, self.scene, self.smart_night_light,
self.delay_off_countdown)
return s


class PhilipsEyecare(Device):
"""Main class representing Xiaomi Philips Eyecare Smart Lamp 2."""

Expand Down Expand Up @@ -84,64 +145,3 @@ def status(self) -> PhilipsEyecareStatus:

return PhilipsEyecareStatus(
defaultdict(lambda: None, zip(properties, values)))


class PhilipsEyecareStatus:
"""Container for status reports from Xiaomi Philips Eyecare Smart Lamp 2"""

def __init__(self, data: Dict[str, Any]) -> None:
# ['power': 'off', 'bright': 5, 'notifystatus': 'off',
# 'ambstatus': 'off': 'ambvalue': 41, 'eyecare': 'on',
# 'scene_num': 3, 'bls': 'on', 'dvalue': 0]
self.data = data

@property
def power(self) -> str:
return self.data["power"]

@property
def is_on(self) -> bool:
return self.power == "on"

@property
def brightness(self) -> int:
return self.data["bright"]

@property
def reminder(self) -> bool:
return self.data["notifystatus"] == "on"

@property
def ambient(self) -> bool:
return self.data["ambstatus"] == "on"

@property
def ambient_brightness(self) -> int:
return self.data["ambvalue"]

@property
def eyecare(self) -> bool:
return self.data["eyecare"] == "on"

@property
def scene(self) -> int:
return self.data["scene_num"]

@property
def smart_night_light(self) -> bool:
return self.data["bls"] == "on"

@property
def delay_off_countdown(self) -> int:
return self.data["dvalue"]

def __str__(self) -> str:
s = "<PhilipsEyecareStatus power=%s, brightness=%s, " \
"notify=%s, ambient=%s, ambient_brightness=%s, " \
"eyecare=%s, scene=%s, smart_night_light=%s, " \
"delay_off_countdown=%s>" % \
(self.power, self.brightness,
self.reminder, self.ambient, self.ambient_brightness,
self.eyecare, self.scene, self.smart_night_light,
self.delay_off_countdown)
return s

0 comments on commit 02307e5

Please sign in to comment.