home-assistant / homebridge-homeassistant

DEPRECATED in favor of native HomeKit support. -  Homebridge plugin for Home Assistant
https://www.home-assistant.io/components/homekit/
Other
683 stars 145 forks source link

Yeelight RGB Bulbs / RGB Strip don't change color. #252

Closed cbrst closed 6 years ago

cbrst commented 6 years ago

When trying to change the color on my Yeelight bulbs through Siri / Home app, the color stays the same, even though the event is reported as successful.

Seems like the bulbs get toggled off and back on with the exact same values.

Changing brightness works. So does changing colors directly through HASS.

Homebridge Log:

[26/11/2017, 17:47:54] [HomeAssistant] Received event: {"event_type": "call_service", "data": {"domain": "light", "service": "turn_on", "service_data": {"entity_id": "light.yeelight_strip_286c07722dd9", "xy_color": ["0.3868", "0.3321"]}, "service_call_id": "4554817040-44"}, "origin": "LOCAL", "time_fired": "2017-11-26T16:47:54.535891+00:00"}
[26/11/2017, 17:47:54] [HomeAssistant] Received event: {"event_type": "call_service", "data": {"domain": "light", "service": "turn_on", "service_data": {"entity_id": "light.yeelight_strip_286c07722dd9", "xy_color": ["0.2774", "0.2857"]}, "service_call_id": "4554817040-45"}, "origin": "LOCAL", "time_fired": "2017-11-26T16:47:54.537676+00:00"}
[26/11/2017, 17:47:54] [HomeAssistant] Received event: {"event_type": "state_changed", "data": {"entity_id": "light.yeelight_strip_286c07722dd9", "old_state": {"entity_id": "light.yeelight_strip_286c07722dd9", "state": "on", "attributes": {"brightness": 255.0, "color_temp": 399, "min_mireds": 153, "max_mireds": 588, "rgb_color": [255, 39, 6], "xy_color": [0.669, 0.328], "effect_list": ["Disco", "Slow Temp", "Strobe epilepsy!", "Strobe color", "Alarm", "Police", "Police2", "Christmas", "RGB", "Random Loop", "Fast Random Loop","Slowdown", "WhatsApp", "Facebook", "Twitter", "Stop"], "friendly_name": "yeelight_strip_286c07722dd9", "supported_features": 127}, "last_changed": "2017-11-26T16:47:27.229764+00:00", "last_updated": "2017-11-26T16:47:27.229764+00:00"}, "new_state": {"entity_id": "light.yeelight_strip_286c07722dd9", "state": "off", "attributes": {"friendly_name": "yeelight_strip_286c07722dd9", "supported_features": 127}, "last_changed": "2017-11-26T16:47:54.549083+00:00", "last_updated": "2017-11-26T16:47:54.549083+00:00"}}, "origin": "LOCAL", "time_fired": "2017-11-26T16:47:54.549126+00:00"}
[26/11/2017, 17:47:54] [HomeAssistant] Received event: {"event_type": "service_executed", "data": {"service_call_id": "4554817040-45"}, "origin": "LOCAL", "time_fired": "2017-11-26T16:47:54.550989+00:00"}
[26/11/2017, 17:47:54] [HomeAssistant] Successfully set hue on the 'yeelight_strip_286c07722dd9' to 222
[26/11/2017, 17:47:54] [HomeAssistant] Successfully set xy on the 'yeelight_strip_286c07722dd9' to 0.2774,0.2857
[26/11/2017, 17:47:54] [HomeAssistant] Received event: {"event_type": "state_changed", "data": {"entity_id": "light.yeelight_strip_286c07722dd9", "old_state": {"entity_id": "light.yeelight_strip_286c07722dd9", "state": "off", "attributes": {"friendly_name": "yeelight_strip_286c07722dd9", "supported_features": 127}, "last_changed": "2017-11-26T16:47:54.549083+00:00", "last_updated": "2017-11-26T16:47:54.549083+00:00"}, "new_state": {"entity_id": "light.yeelight_strip_286c07722dd9", "state": "on", "attributes": {"brightness": 255.0, "color_temp": 399, "min_mireds": 153, "max_mireds": 588, "rgb_color": [255, 39, 6], "xy_color": [0.669, 0.328], "effect_list": ["Disco", "Slow Temp", "Strobe epilepsy!", "Strobe color", "Alarm", "Police", "Police2", "Christmas", "RGB", "Random Loop", "Fast Random Loop", "Slowdown", "WhatsApp", "Facebook", "Twitter", "Stop"], "friendly_name": "yeelight_strip_286c07722dd9", "supported_features": 127}, "last_changed": "2017-11-26T16:47:54.565026+00:00", "last_updated": "2017-11-26T16:47:54.565026+00:00"}}, "origin": "LOCAL", "time_fired": "2017-11-26T16:47:54.565069+00:00"}
[26/11/2017, 17:47:54] [HomeAssistant] Received event: {"event_type": "service_executed", "data": {"service_call_id": "4554817040-44"}, "origin": "LOCAL", "time_fired": "2017-11-26T16:47:54.567323+00:00"}
[26/11/2017, 17:47:54] [HomeAssistant] Successfully set saturation on the 'yeelight_strip_286c07722dd9' to 20
[26/11/2017, 17:47:54] [HomeAssistant] Successfully set xy on the 'yeelight_strip_286c07722dd9' to 0.3868,0.3321

Home Assistant Log:

2017-11-26 17:47:54 INFO (MainThread) [homeassistant.components.http] Serving /api/services/light/turn_on to 127.0.0.1 (auth: True)
2017-11-26 17:47:54 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=light, service=turn_on, service_data=entity_id=light.yeelight_strip_286c07722dd9, xy_color=['0.3868', '0.3321'], service_call_id=4554817040-44>
2017-11-26 17:47:54 INFO (MainThread) [homeassistant.components.http] Serving /api/services/light/turn_on to 127.0.0.1 (auth: True)
2017-11-26 17:47:54 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=light, service=turn_on, service_data=entity_id=light.yeelight_strip_286c07722dd9, xy_color=['0.2774', '0.2857'], service_call_id=4554817040-45>
2017-11-26 17:47:54 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=light.yeelight_strip_286c07722dd9, old_state=<state light.yeelight_strip_286c07722dd9=on; brightness=255.0, color_temp=399, min_mireds=153, max_mireds=588, rgb_color=(255, 39, 6), xy_color=(0.669, 0.328), effect_list=['Disco', 'Slow Temp', 'Strobe epilepsy!', 'Strobe color', 'Alarm', 'Police', 'Police2', 'Christmas', 'RGB', 'Random Loop', 'Fast Random Loop', 'Slowdown', 'WhatsApp', 'Facebook', 'Twitter', 'Stop'], friendly_name=yeelight_strip_286c07722dd9, supported_features=127 @ 2017-11-26T16:47:27.229764+00:00>, new_state=<state light.yeelight_strip_286c07722dd9=off; friendly_name=yeelight_strip_286c07722dd9, supported_features=127 @ 2017-11-26T16:47:54.549083+00:00>>
2017-11-26 17:47:54 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_executed[L]: service_call_id=4554817040-45>
2017-11-26 17:47:54 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=light.yeelight_strip_286c07722dd9, old_state=<state light.yeelight_strip_286c07722dd9=off; friendly_name=yeelight_strip_286c07722dd9, supported_features=127 @2017-11-26T16:47:54.549083+00:00>, new_state=<state light.yeelight_strip_286c07722dd9=on; brightness=255.0, color_temp=399, min_mireds=153, max_mireds=588, rgb_color=(255, 39, 6), xy_color=(0.669, 0.328), effect_list=['Disco', 'Slow Temp', 'Strobe epilepsy!', 'Strobe color', 'Alarm', 'Police', 'Police2', 'Christmas', 'RGB', 'Random Loop', 'Fast Random Loop', 'Slowdown', 'WhatsApp', 'Facebook', 'Twitter', 'Stop'], friendly_name=yeelight_strip_286c07722dd9, supported_features=127 @ 2017-11-26T16:47:54.565026+00:00>>
2017-11-26 17:47:54 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_executed[L]: service_call_id=4554817040-44>
2017-11-26 17:47:54 INFO (MainThread) [homeassistant.components.http] Serving /api/history/period/2017-11-26T16:47:27.288Z to 192.168.1.168 (auth: True)
2017-11-26 17:47:54 INFO (MainThread) [homeassistant.components.http] Serving /api/history/period/2017-11-26T16:47:54.570Z to 192.168.1.168 (auth: True)
honcheng commented 6 years ago

I have the same problem with Yeelight

honcheng commented 6 years ago

So I checked the log in HA when changing color via HA web interface, and it seems to be calling set_rgb. Then I checked light.js

https://github.com/home-assistant/homebridge-homeassistant/blob/05264879c8416ffe7a237e4891156ea7d3f3f700/accessories/light.js#L344:L348

It seems that the failure happens because it tries to set XY color. If I ignore the check for XY_COLOR and just set RGB, it works fine. Just commenting line 344,345,346 and 348 works for me.

So the problem is, are Yeelight indicating that it supports XY color when it does not, or does HA has a bug with XY color setting. HA seems to be just calling set_rgb.

Teri928 commented 6 years ago

i'm still having the same problem with the Yeelight bulbs. I've tried these fixes but it is still trying to use Hue and XY colors instead of RGB. Is there a fix for this yet or I am still doing something wrong?

soumyanegi commented 6 years ago

I am facing the same problem with a OSRAM RGB Flex strip

ollisier commented 6 years ago

how would i comment that out?

knowsnotmuch commented 6 years ago

This worked for me.

@Pickowicko - on hassbian I had to edit this file: sudo nano /usr/lib/node_modules/homebridge-homeassistant/accessories/light.js

I removed the lines mentioned by @honcheng and it works perfectly now. Thank you!

lexbritvin commented 6 years ago

The solution without changing the code is:

  1. Go to Homeassistant web UI -> Configuration tab -> Customization
  2. Select the entity of yeelight
  3. Change property "supported_features" from 127 to 63
  4. Restart homebridge

Changes from UI will be put in customize.yaml.

Or you can put the following configuration in customize.yaml in .homeassistant directory.

light.YEELIGHT_DEVICENAME:
  supported_features: 63

Reload config on Homeassistant web UI -> Configuration tab -> General -> Reload Core

63 is a calculation of SUPPORT_YEELIGHT | SUPPORT_RGB_COLOR | SUPPORT_EFFECT | SUPPORT_COLOR_TEMP without SUPPORT_XY_COLOR, which you can find in Homeassistant source code.

remco770 commented 6 years ago

Solution works also fine with Miilight (limitlessled). You solved my issue! THANKS!

schmittx commented 6 years ago

Please submit a bug report to the Home Assistant repository.

charlietomo commented 6 years ago

Did this ever get reported to Home Assistant? I have searched the issues and not found anything, and I am having the same or a very similar issue.

Hass.io running Home Assistant (0.65.4) and Homebridge (2.3.0), updated to latest versions.

Error with supported_features: 63 in home bridge logs

[2018-3-15 17:35:20] [HomeAssistant] Successfully set hue on the 'Kitchen Under Counter' to 121
[2018-3-15 17:35:20] [HomeAssistant] Successfully set rgb on the 'Kitchen Under Counter' to 0,0,0

Same error with nosupported features in home bridge logs

[2018-3-15 17:43:39] [HomeAssistant] Successfully set hue on the 'Kitchen Under Counter' to 124
[2018-3-15 17:43:39] [HomeAssistant] Successfully set rgb on the 'Kitchen Under Counter' to 0,0,0

and in Home Assistant logs

Error when calling <function YeelightLight.set_rgb at 0x73974e40>: {'code': -5000, 'message': 'general error'}
Error when calling <function YeelightLight.set_default at 0x73974f60>: {'code': -5000, 'message': 'general error'}

All controls work in Home Assistant through web ui (on/off + brightness + temp + colour). Some features work in Home app on iPhone (on/off + brightness + temp) however colour does not work - this is where the errors happen.

Thanks for any assistance. I have not yet resorted to changing files, which seems a bit extreme. Before Home Assistant (just using HomeBridge) the same lights worked including colour via Home app on iPhone.

lzane commented 6 years ago

I use @LexBritvin 's solution and it works fine for every first time.

If I want to change the light color again there are errors occurred. And I can do turn on and change color at the same time using Siri.

The HA logs:

2018-03-28 21:36:05 ERROR (SyncWorker_6) [homeassistant.components.light.yeelight] Error when calling <function YeelightLight.set_default at 0x73d50c48>: Bulb closed the connection.
2018-03-28 21:36:16 ERROR (SyncWorker_16) [homeassistant.components.light.yeelight] Error when calling <function YeelightLight.set_rgb at 0x73d50b28>: Bulb closed the connection.
2018-03-28 21:38:13 ERROR (SyncWorker_2) [homeassistant.components.light.yeelight] Unable to turn the bulb on: {'code': -5000, 'message': 'general error'}
2018-03-28 21:39:45 ERROR (SyncWorker_16) [homeassistant.components.light.yeelight] Unable to update bulb status: Bulb closed the connection.