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 RGB support to the Moonlight #21

Closed
syssi opened this issue Nov 15, 2018 · 11 comments
Closed

Add RGB support to the Moonlight #21

syssi opened this issue Nov 15, 2018 · 11 comments

Comments

@syssi
Copy link
Owner

syssi commented Nov 15, 2018

No description provided.

@syssi
Copy link
Owner Author

syssi commented Dec 8, 2018

Added.

@syssi syssi closed this as completed Dec 8, 2018
@syssi syssi reopened this Dec 9, 2018
@syssi
Copy link
Owner Author

syssi commented Dec 9, 2018

@jake661 You've reported the following issue: Setting color failed: {'code': -5001, 'message': 'param error'}

Thanks for your support! Could you enable the debug output of the component and provide some logs? I'm looking for the miIO request set_rgb and your response (param error):

Just enable the logger:

logger:
  default: warn
  logs:
    custom_components.light.xiaomi_miio: debug
    miio: info

And provide the content of your home-assistant.log

@jake661
Copy link

jake661 commented Dec 10, 2018

Glad to help, thanks for your work! I'm attempting to set the color using the native HA color.py utility. Curious if sertting the color this way is supported? Here is the requested debug log output:

2018-12-10 07:32:08 DEBUG (MainThread) [custom_components.light.xiaomi_miio] Got new state: <PhilipsMoonlightStatus power=on, brightness=85, color_temperature=22, rgb=(240, 10, 255), scene=0>
2018-12-10 07:32:08 DEBUG (MainThread) [custom_components.light.xiaomi_miio] Setting color: <module 'homeassistant.util.color' from '/usr/src/app/homeassistant/util/color.py'>
2018-12-10 07:32:08 ERROR (MainThread) [custom_components.light.xiaomi_miio] Setting color failed: {'code': -5001, 'message': 'param error'} cct"

Screenshot of color.py utility:
image

@syssi
Copy link
Owner Author

syssi commented Dec 10, 2018

This is a bug! I will care about.

@syssi
Copy link
Owner Author

syssi commented Dec 11, 2018

I've fixed the log message. Could you update this configuration to:

logger:
  default: warn
  logs:
    custom_components.light.xiaomi_miio: debug
    miio: info

I'm looking for this lines:

2018-12-11 08:33:36 DEBUG (MainThread) [custom_components.light.xiaomi_miio] Setting color: (255, 0, 0)
2018-12-11 08:33:36 DEBUG (Thread-5) [miio.device] 192.168.130.80:54321 >>: {'method': 'set_rgb', 'id': 4, 'params': [16711680]}
2018-12-11 08:33:36 DEBUG (Thread-5) [miio.device] 192.168.130.80:54321 (ts: 1970-01-01 00:12:51, id: 4) << {'id': 4, 'error': ... }
2018-12-11 08:33:36 ERROR (MainThread) [custom_components.light.xiaomi_miio] Setting color failed: ...

@jake661
Copy link

jake661 commented Dec 11, 2018

Thanks for looking into this. Here are the requested debug logs:

2018-12-11 12:14:08 DEBUG (MainThread) [custom_components.light.xiaomi_miio] Setting color: (0, 127, 255)
2018-12-11 12:14:08 DEBUG (SyncWorker_8) [miio.device] 192.168.29.8:54321 >>: {'id': 18, 'method': 'set_rgb', 'params': [32767]}
2018-12-11 12:14:08 DEBUG (SyncWorker_8) [miio.device] 192.168.29.8:54321 (ts: 1970-01-11 19:22:21, id: 18) << {'error': {'code': -5001, 'message': 'param error'}, 'id': 18}
2018-12-11 12:14:08 ERROR (MainThread) [custom_components.light.xiaomi_miio] Setting color failed: {'code': -5001, 'message': 'param error'}

@syssi
Copy link
Owner Author

syssi commented Dec 11, 2018

Cool. I know what's going on here. Could you try to control the light by the miiocli command line tool (part of python-miio: pip3 install python-miio):

miiocli device --ip IP --token TOKEN raw_command get_prop "['rgb']"
miiocli device --ip IP --token TOKEN raw_command set_rgb "[255,255,255]"
miiocli device --ip IP --token TOKEN raw_command get_prop "['rgb']"
miiocli device --ip IP --token TOKEN raw_command set_rgb "[255,0,0]"
miiocli device --ip IP --token TOKEN raw_command get_prop "['rgb']"
miiocli device --ip IP --token TOKEN raw_command set_rgb "[0,255,0]"
miiocli device --ip IP --token TOKEN raw_command get_prop "['rgb']"
miiocli device --ip IP --token TOKEN raw_command set_rgb "[0,0,255]"
miiocli device --ip IP --token TOKEN raw_command get_prop "['rgb']"

Please provide the output of each command.

@jake661
Copy link

jake661 commented Dec 11, 2018

Here you go:

miiocli device --ip IP --token TOKEN raw_command get_prop "['rgb']"
Running command raw_command
[15731455]

miiocli device --ip IP --token TOKEN raw_command set_rgb "[255,255,255]"
Running command raw_command
['ok']

miiocli device --ip IP --token TOKEN raw_command get_prop "['rgb']"
Running command raw_command
[16777215]

miiocli device --ip IP --token TOKEN raw_command set_rgb "[255,0,0]"
Running command raw_command
['ok']

miiocli device --ip IP --token TOKEN raw_command get_prop "['rgb']"
Running command raw_command
[16711680]

miiocli device --ip IP --token TOKEN raw_command set_rgb "[0,255,0]"
Running command raw_command
['ok']

miiocli device --ip IP --token TOKEN raw_command get_prop "['rgb']"
Running command raw_command
[65280]

miiocli device --ip IP --token TOKEN raw_command set_rgb "[0,0,255]"
Running command raw_command
['ok']

miiocli device --ip IP --token TOKEN raw_command get_prop "['rgb']"
Running command raw_command
[255]

@syssi
Copy link
Owner Author

syssi commented Dec 11, 2018

Perfect! I've updated the component. Plesse give it a try.

@jake661
Copy link

jake661 commented Dec 11, 2018

Excellent, confirmed working now! Thanks again!

@syssi
Copy link
Owner Author

syssi commented Dec 12, 2018

Awesome!

@syssi syssi closed this as completed Dec 12, 2018
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