-
-
Notifications
You must be signed in to change notification settings - Fork 566
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
Added support for Xiaomi Philips Eyecare Smart Lamp 2 #34
Conversation
mirobo/philips_eyecare_cli.py
Outdated
"""Set Ambient Light brightness level.""" | ||
click.echo("Ambient Light Brightness: %s" % dev.set_amb_bright(level)) | ||
|
||
if __name__ == "__main__": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines after class or function definition, found 1
mirobo/philips_eyecare_cli.py
Outdated
"""Ambient Light off.""" | ||
click.echo("Ambient Light Off: %s" % dev.amb_off()) | ||
|
||
@cli.command() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
mirobo/philips_eyecare_cli.py
Outdated
"""Ambient Light on.""" | ||
click.echo("Ambient Light On: %s" % dev.amb_on()) | ||
|
||
@cli.command() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
mirobo/philips_eyecare_cli.py
Outdated
"""Eye Fatigue Reminder off.""" | ||
click.echo("Eye Fatigue Reminder Off: %s" % dev.notify_user_off()) | ||
|
||
@cli.command() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
mirobo/philips_eyecare_cli.py
Outdated
"""Eye Fatigue Reminder On.""" | ||
click.echo("Eye Fatigue Reminder On: %s" % dev.notify_user_on()) | ||
|
||
@cli.command() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
mirobo/philips_eyecare_cli.py
Outdated
"""Power on.""" | ||
click.echo("Power on: %s" % dev.on()) | ||
|
||
@cli.command() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
mirobo/philips_eyecare_cli.py
Outdated
click.echo("Night Light: %s " % res.bls) | ||
click.echo("Delay Off: %s minutes" % res.dvalue) | ||
|
||
@cli.command() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
mirobo/philips_eyecare_cli.py
Outdated
"""Search for plugs in the network.""" | ||
mirobo.PhilipsEyecare.discover() | ||
|
||
@cli.command() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
mirobo/philips_eyecare_cli.py
Outdated
if ctx.invoked_subcommand is None: | ||
ctx.invoke(status) | ||
|
||
@cli.command() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
mirobo/philips_eyecare_cli.py
Outdated
raise click.BadParameter('Should be a positive int between 1-3.') | ||
return value | ||
|
||
def validate_ip(ctx, param, value): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
mirobo/philips_eyecare_cli.py
Outdated
"""Set Ambient Light brightness level.""" | ||
click.echo("Ambient Light Brightness: %s" % dev.set_amb_bright(level)) | ||
|
||
if __name__ == "__main__": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines after class or function definition, found 1
mirobo/philips_eyecare_cli.py
Outdated
"""Ambient Light off.""" | ||
click.echo("Ambient Light Off: %s" % dev.amb_off()) | ||
|
||
@cli.command() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
mirobo/philips_eyecare_cli.py
Outdated
"""Ambient Light on.""" | ||
click.echo("Ambient Light On: %s" % dev.amb_on()) | ||
|
||
@cli.command() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
mirobo/philips_eyecare_cli.py
Outdated
"""Eye Fatigue Reminder off.""" | ||
click.echo("Eye Fatigue Reminder Off: %s" % dev.notify_user_off()) | ||
|
||
@cli.command() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
mirobo/philips_eyecare_cli.py
Outdated
"""Eye Fatigue Reminder On.""" | ||
click.echo("Eye Fatigue Reminder On: %s" % dev.notify_user_on()) | ||
|
||
@cli.command() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
mirobo/philips_eyecare_cli.py
Outdated
"""Power on.""" | ||
click.echo("Power on: %s" % dev.on()) | ||
|
||
@cli.command() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
mirobo/philips_eyecare_cli.py
Outdated
click.echo("Night Light: %s " % res.bls) | ||
click.echo("Delay Off: %s minutes" % res.dvalue) | ||
|
||
@cli.command() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
mirobo/philips_eyecare_cli.py
Outdated
"""Search for plugs in the network.""" | ||
mirobo.PhilipsEyecare.discover() | ||
|
||
@cli.command() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
mirobo/philips_eyecare_cli.py
Outdated
if ctx.invoked_subcommand is None: | ||
ctx.invoke(status) | ||
|
||
@cli.command() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
mirobo/philips_eyecare_cli.py
Outdated
raise click.BadParameter('Should be a positive int between 1-3.') | ||
return value | ||
|
||
def validate_ip(ctx, param, value): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
mirobo/philips_eyecare_cli.py
Outdated
_LOGGER = logging.getLogger(__name__) | ||
pass_dev = click.make_pass_decorator(mirobo.PhilipsEyecare) | ||
|
||
def validate_bright(ctx, param, value): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
mirobo/philips_eyecare_cli.py
Outdated
# -*- coding: UTF-8 -*- | ||
import logging | ||
import click | ||
import ast |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'ast' imported but unused
mirobo/philips_eyecare.py
Outdated
return self.data["dvalue"] | ||
|
||
|
||
def __str__(self) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
too many blank lines (2)
mirobo/philips_eyecare.py
Outdated
@property | ||
def eyecare(self) -> str: | ||
return self.data["eyecare"] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blank line contains whitespace
mirobo/philips_eyecare.py
Outdated
) | ||
return PhilipsEyecareStatus(dict(zip(properties, values))) | ||
|
||
class PhilipsEyecareStatus: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
mirobo/philips_eyecare.py
Outdated
def status(self): | ||
"""Retrieve properties.""" | ||
properties = ['power', 'bright', 'notifystatus', | ||
'ambstatus', 'ambvalue', 'eyecare', 'scene_num', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
continuation line under-indented for visual indent
trailing whitespace
mirobo/philips_eyecare.py
Outdated
|
||
def status(self): | ||
"""Retrieve properties.""" | ||
properties = ['power', 'bright', 'notifystatus', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trailing whitespace
mirobo/philips_eyecare.py
Outdated
def set_user_scene(self, num: int): | ||
"""Set eyecare user scene.""" | ||
return self.send("set_user_scene", [num]) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blank line contains whitespace
mirobo/philips_eyecare.py
Outdated
from typing import Any, Dict | ||
import enum | ||
|
||
class PhilipsEyecare(Device): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
mirobo/philips_eyecare.py
Outdated
@@ -0,0 +1,134 @@ | |||
from .device import Device | |||
from typing import Any, Dict | |||
import enum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'enum' imported but unused
Could you please run |
Device ID is the same one as in this PR, although no idea what is that 55249: 0x02f9: "Xiaomi Philips Eyecare Smart Lamp 2 With this lamp mirobo crashes as it doesn't have get_status method:
|
That's discovery, I mean you have to try |
I just saw my mistake, here's the good one, sorry for the confusion!
|
Thanks, that's looking good! Interesting that it sports ESP8266 (hw_ver) :-) I think this can actually be merged now, it just needs some refactoring after refactoring the client tool to behave nicer. |
As the necessary information for refactoring the client tool is either here or in the source code, let's merge this as I'm unsure when I get some time to look into refactoring the tool. Thanks a lot for the PR 👍 |
Added initial support for Xiaomi Philips Eyecare Smart Lamp 2
Usage: mieye [OPTIONS] COMMAND [ARGS]...
A tool to command Xiaomi Philips Eyecare Smart Lamp 2.
Options:
--ip TEXT
--token TEXT
-d, --debug
--help Show this message and exit.
Commands:
ambient_off Ambient Light off.
ambient_on Ambient Light on.
bl_off Night Light off.
bl_on Night Light on.
delay_off Set delay off in minutes.
discover Search for plugs in the network.
notify_off Eye Fatigue Reminder off.
notify_on Eye Fatigue Reminder On.
off Power off.
on Power on.
set_amb_bright Set Ambient Light brightness level.
set_bright Set brightness level.
set_scene Set eyecare scene number.
status Returns the state information.