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 support for Xiaomi Philips Eyecare Smart Lamp 2 #3

Closed
ghost opened this issue Sep 24, 2017 · 13 comments
Closed

Add support for Xiaomi Philips Eyecare Smart Lamp 2 #3

ghost opened this issue Sep 24, 2017 · 13 comments

Comments

@ghost
Copy link

ghost commented Sep 24, 2017

@syssi Please add support for Xiaomi Philips Eyecare Smart Lamp 2.
It is already supported upstream and is working fine on the command line via the same python-mirobo. Next step should be integration into the home assistant panel.

Easy peasy for you as expert :)

Thanks.

@syssi
Copy link
Owner

syssi commented Sep 25, 2017

If you care about some testing I will implement the additional device soon!

@ghost
Copy link
Author

ghost commented Sep 25, 2017

@syssi sure, I have a test raspberry all in one (home assistant) ready for liftoff.
Lets start with the feature power on, power off.

@syssi
Copy link
Owner

syssi commented Sep 26, 2017

The current implementation should support turning the lamp on and off already. Just give it a try!

@ghost
Copy link
Author

ghost commented Sep 26, 2017

Great. Thanks for your effort.
I've tried it, but unfortunately I have to report to you that it does not work.
The light does not show up in the home assistant panel + error warning as written below.
Has been tried with Hass.io: Supervisor 0.64, Host OS 1.1, Home Assistant 0.54.

Because Xiaomi_miio.py from home assistant upstream seems to be almost the same.

Controlling the light via python-mirobo 0.2.0 on the command line is just working fine.

If the case is to use the Raspberry all in one instead of
Hass.io, the exact files from your repo. Or something else.
Please let me know. My test system is as always ready to liftoff.

Config:

light:
  - platform: xiaomi_miio
    name: Xiaomi Philips Eyecare Smart Lamp 2
    host: 12.12.12.16
    token: ea9405da516b567327f7ccd379116c14

Error:

Traceback (most recent call last):
  File "/usr/lib/python3.6/asyncio/tasks.py", line 179, in _step
    result = coro.send(None)
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 381, in async_process_entity
    new_entity, self, update_before_add=update_before_add
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 210, in async_add_entity
    yield from entity.async_update()
  File "/usr/lib/python3.6/site-packages/homeassistant/components/light/xiaomi_miio.py", line 216, in async_update
    self.max_mireds, self.min_mireds)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/light/xiaomi_miio.py", line 226, in translate
    value_scaled = float(value - left_min) / float(left_span)
TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'

@syssi
Copy link
Owner

syssi commented Sep 27, 2017

You are right. The update method isn't compatible. Could you provide the output of:

mirobo --ip 12.12.12.16 --token ea9405da516b567327f7ccd379116c14 raw_command set_power '["off"]'
mirobo --ip 12.12.12.16 --token ea9405da516b567327f7ccd379116c14 raw_command get_prop '["power", "bright", "notifystatus", "ambstatus", "ambvalue", "eyecare", "scene_num", "bls", "dvalue" ]'
mirobo --ip 12.12.12.16 --token ea9405da516b567327f7ccd379116c14 raw_command set_power '["on"]'
mirobo --ip 12.12.12.16 --token ea9405da516b567327f7ccd379116c14 raw_command get_prop '["power", "bright", "notifystatus", "ambstatus", "ambvalue", "eyecare", "scene_num", "bls", "dvalue" ]'

Thanks!

PS. You are right. The light.xiaomi_miio component is the official version of this philipslight component. I will port new features as far as they are stable.

@ghost
Copy link
Author

ghost commented Sep 27, 2017

Switched back to Raspberry All in one as Hass.io is to closed to test it open and easy.
Please note that Github is an open platform, so I anonymized the token.
If, for whatever reason, you need the real one. Please let me know.

These are the results:

mirobo --ip 12.12.12.16 --token ea9405da516b567327f7ccd379116c14 raw_command set_power '["off"]'

ERROR:mirobo.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']
['ok']

Again to verify whether the error message is gone.

mirobo --ip 12.12.12.16 --token ea9405da516b567327f7ccd379116c14 raw_command set_power '["off"]'

Sending cmd set_power with params ['off']
['ok']

mirobo --ip 12.12.12.16 --token ea9405da516b567327f7ccd379116c14 raw_command get_prop '["power", "bright", "notifystatus", "ambstatus", "ambvalue", "eyecare", "scene_num", "bls", "dvalue" ]'

Sending cmd get_prop with params ['power', 'bright', 'notifystatus', 'ambstatus', 'ambvalue', 'eyecare', 'scene_num', 'bls', 'dvalue']
['off', 100, 'off', 'on', 41, 'on', 1, 'on', 0]

mirobo --ip 12.12.12.16 --token ea9405da516b567327f7ccd379116c14 raw_command set_power '["on"]'

Sending cmd set_power with params ['on']
['ok']

mirobo --ip 12.12.12.16 --token ea9405da516b567327f7ccd379116c14 raw_command get_prop '["power", "bright", "notifystatus", "ambstatus", "ambvalue", "eyecare", "scene_num", "bls", "dvalue" ]'

Sending cmd get_prop with params ['power', 'bright', 'notifystatus', 'ambstatus', 'ambvalue', 'eyecare', 'scene_num', 'bls', 'dvalue']
['on', 39, 'off', 'on', 41, 'on', 1, 'on', 0]

mirobo --ip 12.12.12.16 --token ea9405da516b567327f7ccd379116c14 raw_command set_power '["off"]'

Sending cmd set_power with params ['off']
['ok']

@syssi
Copy link
Owner

syssi commented Sep 27, 2017

Thanks! The token isn't important.

@ghost
Copy link
Author

ghost commented Sep 28, 2017

Ok. Thanks for the clarification.
Looking forward to your Xiaomi Philips Eyecare Smart Lamp 2 implementation.

@syssi
Copy link
Owner

syssi commented Oct 12, 2017

Could you please test the current development branch: https://github.com/syssi/philipslight/tree/develop

@ghost
Copy link
Author

ghost commented Oct 12, 2017

Tested.
Sorry to report but it does not work.
No activity or what so ever on the home assistant states screen.

Error log:

  File "/home/homeassistant/.homeassistant/custom_components/light/xiaomi_philipslight.py", line 228, in async_update
    self._brightness = int(255 * 0.01 * state.brightness)
AttributeError: 'PhilipsEyecareStatus' object has no attribute 'brightness'

Config:

light:
  - platform: xiaomi_philipslight
    name: Xiaomi Philips Eyecare Lamp 2
    host: 12.12.12.16
    token: ea9405da516b567327f7ccd379116c14

@syssi
Copy link
Owner

syssi commented Oct 13, 2017

Alright. I remember again... I'm waiting for a release of python-mirobo/python-miio. The component needs some fixes of the underlying library.

@ghost
Copy link
Author

ghost commented Oct 13, 2017

Ok. Is there a development version of python-mirobo with 'some fixes of the underlying library' available?

syssi added a commit that referenced this issue Oct 21, 2017
@syssi
Copy link
Owner

syssi commented Oct 21, 2017

python-miio 0.3.0 was released tonight. The new release of the custom component supports your device!

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

1 participant