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

Add control option for the second light unit of the Xiaomi Philips Eyecare Smart Lamp 2 #5

Closed
ghost opened this issue Nov 5, 2017 · 24 comments

Comments

@ghost
Copy link

ghost commented Nov 5, 2017

The Xiaomi Philips Eyecare Smart Lamp has two light units.
As shown in the attachment below.

Please add a function to control the second light unit on the back of the lamp.
To operate (on-off) as second light independently of light one.

https://static.afbeeldinguploaden.nl/1711/334447/37pvJEiU.jpg

@syssi
Copy link
Owner

syssi commented Nov 5, 2017

Could you test some API calls and provide some visual feedback? I don't own the device therefore the implementation depends on your feedback.

@ghost
Copy link
Author

ghost commented Nov 5, 2017

Sure.
I'm not a programmer, but I think that should not be a problem.
Is it something like #3 or should it be implemented in https://github.com/rytilahti/python-miio first?

Of course there is no hurry. We'll see how much we get?

@syssi
Copy link
Owner

syssi commented Nov 26, 2017

Could you please test the following commands and provide some feedback:

mieye --ip your-eyecare-ip --token your-token on
mieye --ip your-eyecare-ip --token your-token off
# Which light source turns on/off?
# If you turn on the ambient light can it be turned off by the command above, too?
# If you turn on the night light can it be turned off by the command above, too?

mieye --ip your-eyecare-ip --token your-token ambient_on
mieye --ip your-eyecare-ip --token your-token ambient_off
# Which light source turns on/off?

mieye --ip your-eyecare-ip --token your-token bl_on
mieye --ip your-eyecare-ip --token your-token bl_off
# Which light source turns on/off?

mieye --ip your-eyecare-ip --token your-token notify_on
mieye --ip your-eyecare-ip --token your-token notify_off
# How does the eye fatigue reminder / notifications works exactly? Does the lamp flash sometimes?

mieye --ip your-eyecare-ip --token your-token set_bright 90
# The brightness of which light source changes? One or both?

mieye --ip your-eyecare-ip --token your-token set_amb_bright 90
# The brightness of which light source changes?

Thanks in advance! If the behavior of the lamp is known the implementation will be easy.

@ghost
Copy link
Author

ghost commented Nov 30, 2017

Thanks.
The results can be shown as follows:

mieye --ip your-eyecare-ip --token your-token on
mieye --ip your-eyecare-ip --token your-token off

  • Which light source turns on/off?

If light 1 is on, light 1 gets off.
If light 1 is on, and light 2 is on, both are on and off.

But. The lamp saves the last setting.
For example. If 2 light were on before the lamp was last turned off.
2 lights will go on and off with this command.

  • If you turn on the ambient light can it be turned off by the command above, too?
  • If you turn on the night light can it be turned off by the command above, too?
  1. Yes.
  2. No clear change to night light or light change in general.

mieye --ip your-eyecare-ip --token your-token ambient_on
mieye --ip your-eyecare-ip --token your-token ambient_off

  • Which light source turns on/off?

If the light is off completely both lights are going on.
If light 1 is on, with this command light 2 is going on or off.

mieye --ip your-eyecare-ip --token your-token bl_on
mieye --ip your-eyecare-ip --token your-token bl_off

  • Which light source turns on/off?

If the light is off completely none of the lights are on.
If light 1, 2 of both are on, no clear change to night light or light change in general.

mieye --ip your-eyecare-ip --token your-token notify_on
mieye --ip your-eyecare-ip --token your-token notify_off

  • How does the eye fatigue reminder / notifications works exactly? Does the lamp flash sometimes?

I do not see any difference, nothing happens, but it may only work in the long term.
In case of a tired user (fatigue).

If there are any questions, I would love to hear them.
light

@syssi
Copy link
Owner

syssi commented Nov 30, 2017

Did I understand your description correctly:

  1. The command "bl_on", "bl_off" doesn't have any effect? Does it return "[ok]" nevertheless?
  2. Light 1 and light 2 cannot controlled (toggled) independently? What's the command to achieve this state: "light1 on, light2 off" vs. "light1 off, light2 on". We need to know the previous state always, right?

@ghost
Copy link
Author

ghost commented Nov 30, 2017

  1. Yes it does return. Night Light On: ['ok']
    If the lamp is off completely nothing happens, lamp stays off.
    If the lamp is on, nothing visually changed.
  2. It seems indeed that the last state is remembered.

The secondary light 2 seems to be connected to light 1 on the "on" switch but not "off" switch.
For example the start situation; The lamp is completely off.

The command "ambient_on" ensures that both lights (1 and 2) turn on.
Using "ambient_off" afterwards only light 2 goes out.
Light 1 then remains on.

If you then switch the lamp off and on again. "off - on" The latest known situation applies.
And that is in this example: Only Light 1 turns on.

@ghost
Copy link
Author

ghost commented Dec 14, 2017

If you want to know something else, I'd love to hear it.

@HA-TB303
Copy link

@buikdaanser

Could you be so kind to help me on my way getting this light to work in HA?

I have extracted the key using the iphone backup method, git this key (slightly modified):

eb6d34d06b5117af2269c7fb8073baada432c5dec773793391a5ff4e136a12500143db63ee66b0cdff9f69917680151e

Which I then converted on my macbook using terminal command:

echo '0: eb6d34d06b5117af2269c7fb8073baada432c5dec773793391a5ff4e136a12500143db63ee66b0cdff9f69917680151e' | xxd -r -p | openssl enc -d -aes-128-ecb -nopad -nosalt -K 00000000000000000000000000000000

The output looked like:

ae3e5e0b1226814f1ed5de36fc243413

However If i use that token, the component in HA times out :(

Also trying:

mirobo --ip 192.168.2.238 --token ae3e5e0b1226814f1ed5de36fc243413 raw_command set_power '["off"]'
ERROR:miio.vacuum_cli:Unable to read the stored msgid: [Errno 2] No such file or directory: '/tmp/python-mirobo.seq'
Sending cmd set_power with params ['off']
ERROR:miio.device:Got error when receiving: timed out
WARNING:miio.device:Retrying with incremented id, retries left: 3
ERROR:miio.device:Got error when receiving: timed out
WARNING:miio.device:Retrying with incremented id, retries left: 2
ERROR:miio.device:Got error when receiving: timed out
WARNING:miio.device:Retrying with incremented id, retries left: 1

Any idea as to what I am doing wrong?

@ghost
Copy link
Author

ghost commented Dec 18, 2017

@Michel72
I do not own an iPhone.
In terms of extracting and converting iPhone keys, I don't know.

About the Xiaomi Philips Eyecare Smart Lamp 2.
Seems you are using the old python-mirobo and /or trying to command the Xiaomi vacuum cleaner.
The old python-mirobo does not support the Xiaomi Philips Eyecare Smart Lamp 2.

Please make sure that you are running the latest python-miio software.
Afterwards you could start controlling your lamp by:

mieye --ip your-eyecare-ip --token your-token on

@HA-TB303
Copy link

Hi,

root@UBTSRV:/home/michel# mieye --ip 192.168.2.74 --token ae3e5e0b1226814f1ed5de36fc243413 on
ERROR:miio.device:Got error when receiving: timed out
WARNING:miio.device:Retrying with incremented id, retries left: 3
ERROR:miio.device:Got error when receiving: timed out
WARNING:miio.device:Retrying with incremented id, retries left: 2

I'll try extracting the key again using a borrowed android phone.

@HA-TB303
Copy link

HA-TB303 commented Dec 19, 2017

Hi,

I extracted the token using an android phone which looks like:

# miio-extract-tokens --password 1234 backup.ab
Saving database to /tmp/tmpv042yy3u
INFO:miio.extract_tokens:Reading database from /tmp/tmpv042yy3u
INFO:miio.extract_tokens:Reading tokens from Android DB
飞利浦智睿台灯二代
	Model: philips.light.sread1
	IP address: 192.168.2.74
	Token: 459ca90868c14f255e7231d964219a51
	MAC: 28:6C:07:A7:64:D8

However.....

# mieye --ip 192.168.2.74 --token 459ca90868c14f255e7231d964219a51 on
ERROR:miio.device:Got error when receiving: timed out
WARNING:miio.device:Retrying with incremented id, retries left: 3
ERROR:miio.device:Got error when receiving: timed out
WARNING:miio.device:Retrying with incremented id, retries left: 2

Is there something else I could try?

Thx,

Michel

@ghost
Copy link
Author

ghost commented Dec 19, 2017

Are you sure that you don't have an router that blocks the connection (i.e. firewall),
About python-mirobo? Does it work well with other devices?

@ghost
Copy link
Author

ghost commented Jan 25, 2018

@syssi any progress on this one?

@syssi
Copy link
Owner

syssi commented Jan 25, 2018

Jep! I started yesterday and will be ready next week!

@ghost
Copy link
Author

ghost commented Jan 26, 2018

Great! Thanks.

@syssi
Copy link
Owner

syssi commented Jan 26, 2018

Do you agree it doesn't make sense to implement the second light ("light 2") as light entity in home assistant because we are unable to turn on and off light 2 independently? I will provide a service per method.

@syssi
Copy link
Owner

syssi commented Jan 26, 2018

If you use the mihome app it's possible to control both lights independently and ignore the saved state? Oooh! I missed something:

mirobo --ip 192.168.0.25 --token 689c4056fe28ebb3a2e8c2fe350e51ba raw_command set_eyecare '["on"]'
mirobo --ip 192.168.0.25 --token 689c4056fe28ebb3a2e8c2fe350e51ba raw_command set_eyecare '["off"]'

Which light is controlled?

@syssi
Copy link
Owner

syssi commented Jan 26, 2018

Please check out the develop branch and give it a try. It can be used as custom_component and will override the official light.xiaomi_miio component: https://github.com/syssi/philipslight/archive/develop.zip

@syssi
Copy link
Owner

syssi commented Feb 13, 2018

@buikdaanser Any progress on testing this one? ;-)

@ghost
Copy link
Author

ghost commented Feb 15, 2018

Thanks.
Was on vacation and became ill on return.
I look at it as quickly as possible.

@syssi
Copy link
Owner

syssi commented Feb 26, 2018

@buikdaanser Do you own a rooted android device? I would like to request some data (mihome plugin apk). I will provide instructions on demand.

@syssi
Copy link
Owner

syssi commented Feb 26, 2018

I'm pretty sure now: The lights can be controlled independently:

mirobo raw_command set_eyecare "['on']"
mirobo raw_command set_eyecare "['off']"

Is the main light controllable with this commands?

@syssi
Copy link
Owner

syssi commented Feb 28, 2018

The device is represented as two light entities now (eyecare light, ambient light). The feature is untested!

@syssi syssi closed this as completed Feb 28, 2018
@ghost
Copy link
Author

ghost commented Jun 12, 2018

@syssi due to a ski accident (broken leg), I could not respond earlier. I can respond at least now. Thanks for your feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants