Added support for Xiaomi Philips Eyecare Smart Lamp 2#34
Added support for Xiaomi Philips Eyecare Smart Lamp 2#34rytilahti merged 3 commits intorytilahti:masterfrom
Conversation
| """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.
expected 2 blank lines after class or function definition, found 1
| """Ambient Light off.""" | ||
| click.echo("Ambient Light Off: %s" % dev.amb_off()) | ||
|
|
||
| @cli.command() |
| """Ambient Light on.""" | ||
| click.echo("Ambient Light On: %s" % dev.amb_on()) | ||
|
|
||
| @cli.command() |
| """Eye Fatigue Reminder off.""" | ||
| click.echo("Eye Fatigue Reminder Off: %s" % dev.notify_user_off()) | ||
|
|
||
| @cli.command() |
| """Eye Fatigue Reminder On.""" | ||
| click.echo("Eye Fatigue Reminder On: %s" % dev.notify_user_on()) | ||
|
|
||
| @cli.command() |
| """Power on.""" | ||
| click.echo("Power on: %s" % dev.on()) | ||
|
|
||
| @cli.command() |
| click.echo("Night Light: %s " % res.bls) | ||
| click.echo("Delay Off: %s minutes" % res.dvalue) | ||
|
|
||
| @cli.command() |
| """Search for plugs in the network.""" | ||
| mirobo.PhilipsEyecare.discover() | ||
|
|
||
| @cli.command() |
| if ctx.invoked_subcommand is None: | ||
| ctx.invoke(status) | ||
|
|
||
| @cli.command() |
| raise click.BadParameter('Should be a positive int between 1-3.') | ||
| return value | ||
|
|
||
| def validate_ip(ctx, param, value): |
| """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.
expected 2 blank lines after class or function definition, found 1
| """Ambient Light off.""" | ||
| click.echo("Ambient Light Off: %s" % dev.amb_off()) | ||
|
|
||
| @cli.command() |
| """Ambient Light on.""" | ||
| click.echo("Ambient Light On: %s" % dev.amb_on()) | ||
|
|
||
| @cli.command() |
| """Eye Fatigue Reminder off.""" | ||
| click.echo("Eye Fatigue Reminder Off: %s" % dev.notify_user_off()) | ||
|
|
||
| @cli.command() |
| """Eye Fatigue Reminder On.""" | ||
| click.echo("Eye Fatigue Reminder On: %s" % dev.notify_user_on()) | ||
|
|
||
| @cli.command() |
| """Power on.""" | ||
| click.echo("Power on: %s" % dev.on()) | ||
|
|
||
| @cli.command() |
| click.echo("Night Light: %s " % res.bls) | ||
| click.echo("Delay Off: %s minutes" % res.dvalue) | ||
|
|
||
| @cli.command() |
| """Search for plugs in the network.""" | ||
| mirobo.PhilipsEyecare.discover() | ||
|
|
||
| @cli.command() |
| if ctx.invoked_subcommand is None: | ||
| ctx.invoke(status) | ||
|
|
||
| @cli.command() |
| raise click.BadParameter('Should be a positive int between 1-3.') | ||
| return value | ||
|
|
||
| def validate_ip(ctx, param, value): |
| _LOGGER = logging.getLogger(__name__) | ||
| pass_dev = click.make_pass_decorator(mirobo.PhilipsEyecare) | ||
|
|
||
| def validate_bright(ctx, param, value): |
mirobo/philips_eyecare_cli.py
Outdated
| # -*- coding: UTF-8 -*- | ||
| import logging | ||
| import click | ||
| import ast |
| return self.data["dvalue"] | ||
|
|
||
|
|
||
| def __str__(self) -> str: |
mirobo/philips_eyecare.py
Outdated
| @property | ||
| def eyecare(self) -> str: | ||
| return self.data["eyecare"] | ||
|
|
| ) | ||
| return PhilipsEyecareStatus(dict(zip(properties, values))) | ||
|
|
||
| class PhilipsEyecareStatus: |
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.
continuation line under-indented for visual indent
trailing whitespace
mirobo/philips_eyecare.py
Outdated
|
|
||
| def status(self): | ||
| """Retrieve properties.""" | ||
| properties = ['power', 'bright', 'notifystatus', |
mirobo/philips_eyecare.py
Outdated
| def set_user_scene(self, num: int): | ||
| """Set eyecare user scene.""" | ||
| return self.send("set_user_scene", [num]) | ||
|
|
| from typing import Any, Dict | ||
| import enum | ||
|
|
||
| class PhilipsEyecare(Device): |
mirobo/philips_eyecare.py
Outdated
| @@ -0,0 +1,134 @@ | |||
| from .device import Device | |||
| from typing import Any, Dict | |||
| import enum | |||
|
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.