Skip to content

Commit

Permalink
Adjust property names of some devices as preparation for refactoring …
Browse files Browse the repository at this point in the history
…(inheritance of properties).
  • Loading branch information
syssi committed Sep 6, 2017
1 parent b374872 commit e6ce549
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 57 deletions.
6 changes: 3 additions & 3 deletions mirobo/airpurifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def child_lock(self) -> bool:
return self.data["child_lock"] == "on"

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

@property
Expand All @@ -185,12 +185,12 @@ def motor_speed(self) -> int:
def __str__(self) -> str:
s = "<AirPurifierStatus power=%s, aqi=%s temperature=%s, " \
"humidity=%s%%, mode=%s, led=%s, led_brightness=%s, buzzer=%s, " \
"child_lock=%s, bright=%s, favorite_level=%s, " \
"child_lock=%s, brightness=%s, favorite_level=%s, " \
"filter_life_remaining=%s, filter_hours_used=%s, " \
"use_time=%s, motor_speed=%s>" % \
(self.power, self.aqi, self.temperature, self.humidity, self.mode,
self.led, self.led_brightness, self.buzzer, self.child_lock,
self.bright, self.favorite_level, self.filter_life_remaining,
self.brightness, self.favorite_level, self.filter_life_remaining,
self.filter_hours_used, self.use_time,
self.motor_speed)
return s
6 changes: 3 additions & 3 deletions mirobo/ceil.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def scene(self) -> int:
return self.data["snm"]

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

@property
Expand All @@ -50,10 +50,10 @@ def automatic_color_temperature(self) -> int:

def __str__(self) -> str:
s = "<CeilStatus power=%s, brightness=%s, " \
"color_temperature=%s, scene=%s, dv=%s, " \
"color_temperature=%s, scene=%s, delay_off_countdown=%s, " \
"smart_night_light=%s, automatic_color_temperature=%s>" % \
(self.power, self.brightness,
self.color_temperature, self.scene, self.dv,
self.color_temperature, self.scene, self.delay_off_countdown,
self.smart_night_light, self.automatic_color_temperature)
return s

Expand Down
3 changes: 2 additions & 1 deletion mirobo/ceil_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@ def status(dev: mirobo.Ceil):
click.echo("Brightness: %s" % res.brightness)
click.echo("Color temperature: %s" % res.color_temperature)
click.echo("Scene: %s" % res.scene)
click.echo("dv: %s" % res.dv)
click.echo("Smart Night Light: %s" % res.smart_night_light)
click.echo("Auto CCT: %s" % res.automatic_color_temperature)
click.echo("Countdown of the delayed turn off: %s seconds"
% res.delay_off_countdown)


@cli.command()
Expand Down
61 changes: 31 additions & 30 deletions mirobo/philips_eyecare.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,43 +21,43 @@ def eyecare_off(self):
"""Eyecare off."""
return self.send("set_eyecare", ["off"])

def set_bright(self, level: int):
def set_brightness(self, level: int):
"""Set brightness level."""
return self.send("set_bright", [level])

def set_user_scene(self, num: int):
def set_scene(self, num: int):
"""Set eyecare user scene."""
return self.send("set_user_scene", [num])

def delay_off(self, minutes: int):
"""Set delay off minutes."""
return self.send("delay_off", [minutes])

def bl_on(self):
def smart_night_light_on(self):
"""Night Light On."""
return self.send("enable_bl", ["on"])

def bl_off(self):
def smart_night_light_off(self):
"""Night Light Off."""
return self.send("enable_bl", ["off"])

def notify_user_on(self):
"""Notify User On."""
def reminder_on(self):
"""Eye Fatigue Reminder On."""
return self.send("set_notifyuser", ["on"])

def notify_user_off(self):
"""Notify USer Off."""
def reminder_off(self):
"""Eye Fatigue Reminder Off."""
return self.send("set_notifyuser", ["off"])

def amb_on(self):
def ambient_on(self):
"""Amblient Light On."""
return self.send("enable_amb", ["on"])

def amb_off(self):
def ambient_off(self):
"""Ambient Light Off."""
return self.send("enable_amb", ["off"])

def set_amb_bright(self, level: int):
def set_ambient_brightness(self, level: int):
"""Set Ambient Light brightness level."""
return self.send("set_amb_bright", [level])

Expand Down Expand Up @@ -91,43 +91,44 @@ def is_on(self) -> bool:
return self.power == "on"

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

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

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

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

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

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

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

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

def __str__(self) -> str:
s = "<PhilipsEyecareStatus power=%s, bright=%s, " \
"notifystatus=%s, ambstatus=%s, ambvalue=%s, " \
"eyecare=%s, scene_num=%s, bls=%s, " \
"dvalue=%s >" % \
(self.power, self.bright,
self.notifystatus, self.ambstatus, self.ambvalue,
self.eyecare, self.scene_num, self.bls, self.dvalue)
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
34 changes: 18 additions & 16 deletions mirobo/philips_eyecare_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,15 @@ def status(dev: mirobo.PhilipsEyecare):
return # bail out

click.echo(click.style("Power: %s" % res.power, bold=True))
click.echo("Brightness: %s" % res.bright)
click.echo("Eye Fatigue Reminder: %s" % res.notifystatus)
click.echo("Ambient Light: %s" % res.ambstatus)
click.echo("Ambient Light Brightness: %s" % res.ambvalue)
click.echo("Brightness: %s" % res.brightness)
click.echo("Eye Fatigue Reminder: %s" % res.reminder)
click.echo("Ambient Light: %s" % res.ambient)
click.echo("Ambient Light Brightness: %s" % res.ambient_brightness)
click.echo("Eyecare Mode: %s" % res.eyecare)
click.echo("Eyecare Scene: %s" % res.scene_num)
click.echo("Night Light: %s " % res.bls)
click.echo("Delay Off: %s minutes" % res.dvalue)
click.echo("Eyecare Scene: %s" % res.scene)
click.echo("Night Light: %s " % res.smart_night_light)
click.echo("Countdown of the delayed turn off: %s minutes"
% res.delay_off_countdown)


@cli.command()
Expand All @@ -126,15 +127,15 @@ def off(dev: mirobo.PhilipsEyecare):
@pass_dev
def set_bright(dev: mirobo.PhilipsEyecare, level):
"""Set brightness level."""
click.echo("Brightness: %s" % dev.set_bright(level))
click.echo("Brightness: %s" % dev.set_brightness(level))


@cli.command()
@click.argument('scene', callback=validate_scene, required=True,)
@pass_dev
def set_scene(dev: mirobo.PhilipsEyecare, scene):
"""Set eyecare scene number."""
click.echo("Eyecare Scene: %s" % dev.set_user_scene(scene))
click.echo("Eyecare Scene: %s" % dev.set_scene(scene))


@cli.command()
Expand All @@ -149,50 +150,51 @@ def delay_off(dev: mirobo.PhilipsEyecare, minutes):
@pass_dev
def bl_on(dev: mirobo.PhilipsEyecare):
"""Night Light on."""
click.echo("Night Light On: %s" % dev.bl_on())
click.echo("Night Light On: %s" % dev.smart_night_light_on())


@cli.command()
@pass_dev
def bl_off(dev: mirobo.PhilipsEyecare):
"""Night Light off."""
click.echo("Night Light off: %s" % dev.bl_off())
click.echo("Night Light off: %s" % dev.smart_night_light_off())


@cli.command()
@pass_dev
def notify_on(dev: mirobo.PhilipsEyecare):
"""Eye Fatigue Reminder On."""
click.echo("Eye Fatigue Reminder On: %s" % dev.notify_user_on())
click.echo("Eye Fatigue Reminder On: %s" % dev.reminder_on())


@cli.command()
@pass_dev
def notify_off(dev: mirobo.PhilipsEyecare):
"""Eye Fatigue Reminder off."""
click.echo("Eye Fatigue Reminder Off: %s" % dev.notify_user_off())
click.echo("Eye Fatigue Reminder Off: %s" % dev.reminder_off())


@cli.command()
@pass_dev
def ambient_on(dev: mirobo.PhilipsEyecare):
"""Ambient Light on."""
click.echo("Ambient Light On: %s" % dev.amb_on())
click.echo("Ambient Light On: %s" % dev.ambient_on())


@cli.command()
@pass_dev
def ambient_off(dev: mirobo.PhilipsEyecare):
"""Ambient Light off."""
click.echo("Ambient Light Off: %s" % dev.amb_off())
click.echo("Ambient Light Off: %s" % dev.ambient_off())


@cli.command()
@click.argument('level', callback=validate_bright, required=True,)
@pass_dev
def set_amb_bright(dev: mirobo.PhilipsEyecare, level):
"""Set Ambient Light brightness level."""
click.echo("Ambient Light Brightness: %s" % dev.set_amb_bright(level))
click.echo("Ambient Light Brightness: %s" %
dev.set_ambient_brightness(level))


if __name__ == "__main__":
Expand Down
8 changes: 4 additions & 4 deletions mirobo/yeelight.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def is_on(self) -> bool:
return self.data["power"] == "on"

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

@property
Expand Down Expand Up @@ -52,11 +52,11 @@ def name(self) -> str:
return self.data["name"]

def __repr__(self):
s = "<Yeelight on=%s mode=%s bright=%s color_temp=%s " \
s = "<Yeelight on=%s mode=%s brightness=%s color_temp=%s " \
"rgb=%s hsv=%s name=%s>" % \
(self.is_on,
self.color_mode,
self.bright,
self.brightness,
self.color_temp,
self.rgb,
self.hsv,
Expand Down Expand Up @@ -86,7 +86,7 @@ def off(self):
"""Power off."""
return self.send("set_power", ["off"])

def set_bright(self, bright):
def set_brightness(self, bright):
return self.send("set_bright", [bright])

def set_color_temp(self, ct):
Expand Down

0 comments on commit e6ce549

Please sign in to comment.