home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.13k stars 29.8k forks source link

Flux RGBW Bulb Error on light.turn_on #15566

Closed rrubin0 closed 5 years ago

rrubin0 commented 6 years ago

Home Assistant release with the issue: 0.73.1

Last working Home Assistant release (if known): 0.72.1 ( worked perfectly )

Operating environment (Hass.io/Docker/Windows/etc.): Hassio running on Ubuntu Server

Component/platform: Flux (RGBW) LED Light Bulb

Description of problem: Unable to perform light.turn_on in 0.73.1 (LoveLace UI) Effects still function using UI light.turn_off still functions using UI

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

light:
  ### office desk lamp
  - platform: flux_led
    devices:
      !secret office_desk_lamp_host:
        name: office_desk_lamp
#
# if using the developer console services, light no longer turns on but turns off via this method:
Service
light.turn_on

Entity
light.office_desk_lamp

Service Data (JSON, optional)
{
  "entity_id": "light.office_desk_lamp"
}

Traceback (if applicable):

2018-07-19 22:29:34 ERROR (MainThread) [homeassistant.core] Error executing service <ServiceCall light.turn_on: entity_id=['light.office_desk_lamp']>
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/core.py", line 1021, in _event_to_service_call
    await service_handler.func(service_call)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/light/__init__.py", line 360, in async_handle_light_service
    await light.async_turn_on(**params)
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/light/flux_led.py", line 266, in turn_on
    self._bulb.setRgbw(*tuple(rgb), w=white, brightness=brightness)
  File "/usr/lib/python3.6/site-packages/flux_led/__main__.py", line 868, in setRgbw
    raise Exception
Exception

Additional information:

rrubin0 commented 6 years ago

If I select a color, the light does not respond. However, if I then physically switch the light off and back on, the color that was selected is the one that the bulb displays. I am then able to call "effects" and am able to turn the light off using controls in hass.

Note: I had just refreshed all of the yaml related to this light to fix minor annoyances in 0.72.1 prior to switching over to Lovelace. So far this is the first component issue that i have experienced using Lovelace over the default UI; however, switching to default UI has same result

rrubin0 commented 6 years ago

Tested in 0.74.0. Able to turn the light on if the previous setting was an effect, but not if it was set to a solid color (need to cycle power for that) I'm able to turn the light off via hass; unable to select colors, but am able to change effects

rrubin0 commented 6 years ago

Still an issue in 0.74.2 selecting any effect from the entities pop up menu functions correctly; however: simply attempting to turn the light on results in:

2018-07-26 21:05:29 ERROR (MainThread) [homeassistant.core] Error executing service <ServiceCall light.turn_on: entity_id=['light.office_desk_lamp'], hs_color=(135.0, 100.0)>
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/core.py", line 1038, in _event_to_service_call
    await service_handler.func(service_call)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/light/__init__.py", line 360, in async_handle_light_service
    await light.async_turn_on(**params)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/light/flux_led.py", line 269, in turn_on
    self._bulb.setRgbw(*tuple(rgb), w=white, brightness=brightness)
  File "/usr/local/lib/python3.6/site-packages/flux_led/__main__.py", line 868, in setRgbw
    raise Exception
Exception

Additionally, this error occurs on each attempt to select a color from the picker within the pop up menu service light.turn_off functions correctly.

amelchio commented 6 years ago

This is confusing. Can you list just a single sequence of steps that do not work as expected?

Do not mention a lot of stuff that does work :)

rrubin0 commented 6 years ago

Thanks for looking! Essentially what doesn’t work: Turning the light on any time a solid color is selected.

Details: — Turning the light on via previously working input selections fail — Color picker does not work

amelchio commented 6 years ago

This exception is raised because "RGBW command sent to non-RGBW device".

I suggest you try adding mode: rgb to your configuration:

light:
  ### office desk lamp
  - platform: flux_led
    devices:
      !secret office_desk_lamp_host:
        name: office_desk_lamp
        mode: rgb
rrubin0 commented 6 years ago

Thanks for the tip but that is not correct. The bulb is indeed RGBW. Note that everything was working perfectly in 0.72.1 prior to updating.

Also note that I’m still able to call any “effect” ...the error occurs when a solid color is selected or if light.turn_on command is issued when light was previously set to a solid color.

amelchio commented 6 years ago

Try it anyway.

ghost commented 6 years ago

I'm seeing this error also popping up in the log. I have a Magiclight v7 and if I set the mode: rgbw, it throws an error on line 868 (rgbw to a nonRGB bulb?) but it is a rgbw bulb. If I set it to mode: rgb it's fine. If I don't add mode it defaults to rgbw and throws the error. How can I see what the software thinks it is, i.e. command line call for debugging info?

rrubin0 commented 6 years ago

@amelchio I tried it. Setting to RGB worked as expected and corrected the issue of not being able to turn on the light or select colors; however, I'm (obviously) unable to select "warm" white color, which I was able to do previously. I appreciate the suggestion but I still have a problem here...

I believe there was a change between 0.72.1 and 0.73+ that caused this.

amelchio commented 6 years ago

That's odd, as far as I can see flux_led has never supported color temperature.

rrubin0 commented 6 years ago

Not sure what to tell you ... it truly is an RGBW bulb ... in version 0.72.1 I had WORKING automations to switch between warm white light (2700K/typical lamp) and colors or 'cool'/daylight light. This was with the default config (RGBW) ... RGB works as far as turning the light on/off goes, but I've lost my most-used, warm white setting. 😞

rrubin0 commented 6 years ago

Again ... something between changes from 0.72.1 to ~0.73 caused the issue.

amelchio commented 6 years ago

I think that I see the issue now. Your bulb probably has RGB and W light but cannot set both at the same time. This was indeed changed in 0.73, to support lights that do have that ability.

Can you post those automations that used to work?

rrubin0 commented 6 years ago

https://github.com/rrubin0/hassio-config/blob/master/packages/office.yaml this was my working config on 0.72.1. Warm white was working great.

On Tue, Aug 7, 2018 at 11:12 PM Anders Melchiorsen notifications@github.com wrote:

I think that I see the issue now. Your bulb probably has RGB and W light but cannot set both at the same time. This was indeed changed in 0.73, to support lights that do have that ability.

Can you post those automations that used to work?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/home-assistant/home-assistant/issues/15566#issuecomment-411297216, or mute the thread https://github.com/notifications/unsubscribe-auth/AUT6RIf2QRG2HxoLVfthINYamvifOBUDks5uOoFAgaJpZM4VXfBB .

rrubin0 commented 6 years ago

still no love ... have not yet upgraded to 0.76.x since nothing is in the release notes for a fix. Flux light still not working properly. If anyone could look into it, I'd appreciate it...or if someone has a workaround / sees a problem with my code, then let me know. thanks!

amelchio commented 6 years ago

You did not yet post the relevant configuration as requested.

Looking at the code though, it seems that providing just a brightness value used to toggle on a white mode before 0.73. This was wrong because setting a new brightness level should not change the color. However, fixing that issue has then removed the ability to activate the white mode for bulbs of type rgb.

Let's see if @oblogic7 is around to comment.

amelchio commented 6 years ago

Actually, that appears to be 0.68 working like that, I see no code in 0.72.1 that could enable the white mode.

Anyway, I just wanted to add that you can upgrade Home Assistant and copy an old flux_led.py to <config>/custom_components/light/flux_led.py to downgrade just the flux_led light module.

oblogic7 commented 6 years ago

The changes I made to the flux component were only tested against RGBW controllers. I do not currently have any bulbs.

@rrubin0 If you can link me to the exact bulb you are using I'll be glad to purchase one and try to figure out why it is not behaving as expected.

rrubin0 commented 6 years ago

@amelchio I posted a link to the configuration just above my last post a couple of weeks ago. That is a good idea, replacing just the .py code ... maybe I'll give that a shot.

@oblogic7 thanks for looking at this! The bulb I have is the first gen version of this one: https://www.amazon.com/dp/B01KJEKDFS?m=A1387MCC2SPAIV&th=1

I believe it has been redesigned since I purchased, as mine has the heat sink fins around it. . . It's been a good RGBW bulb for a while now tho. I got it cheap on sale but I'm sure other users who invested in them would be upset that the code is not working properly.

rrubin0 commented 6 years ago

@amelchio Yo man, great idea! I copied the working 0.72.1 flux_led.py to my custom components folder and am happy to report that I once again have full RGBW control over my Flux LED bulb!

This is a suitable workaround until a more permanent solution can be developed. Thank you all.

amelchio commented 6 years ago

I am confused that 0.72.1 works for you. Can you do a sha1sum or something to verify that we are looking at the same file?

rrubin0 commented 6 years ago

HASH of flux.py for version 0.72.1 image

HASH of flux.py for version 0.76.2 image

definitely changes to "white" and "brightnes" line 263 from working code looks interesting and was deleted in later code:


        if white is not None:
            self._bulb.setWarmWhite255(white)
amelchio commented 6 years ago

Please tell me why you have added white_value to your linked config.

rrubin0 commented 6 years ago

Well, it's in the docs :) I added it as part of my troubleshooting the last time that the component broke my bulb's behavior. It started working and so I left it. It can probably be removed. I will test that and report back asap. Thanks for the continued support too!!

amelchio commented 6 years ago

So rather than copy/pasting the relevant automation that I asked for, you point me at 500 lines of configuration that does not even match what you are using 😖

rrubin0 commented 6 years ago

Not totally sure what you’re talking about but I did recently update my github so, apologies if previous link has broken.

My flux configuration is here now and is relevant to this thread:

https://github.com/rrubin0/homeassistant-config/blob/master/packages/office.yaml

amelchio commented 6 years ago

If somebody wants to fix this, I propose using setWarmWhite255() for white_value, setRgb() for hs_color and only setRgbw() if both white_value and hs_color is specified.

Also include SUPPORT_WHITE_VALUE for MODE_RGB in supported_features() and don't test for MODE_RGBW in turn_on().

That should do it :-)

oblogic7 commented 6 years ago

I believe I tried a similar approach when I added separate control of white_value. I don't remember why it didn't work out. The bulb I ordered came in today, but I am heading out of town for the holiday weekend tonight. Hopefully I will have some time on Monday to take a look and see if I can work on it.

rrubin0 commented 6 years ago

@oblogic7 Hey man, Hope you had a great Labor Day Weekend. I appreciate you looking into this and going so far as to purchase a bulb. Thank you again for the contribution to the community!

oblogic7 commented 6 years ago

I was able to track this down to the flux_led library that HA uses to communicate with the bulb. The bulb is definitely capable of RGBW, but the library was not looking for the value returned by this bulb when checking for RGBW capability.

I have a PR open on the library. Once that is merged, we can bump the library version on the flux_led component for HA and all should be good. The library repo is owned by @Danielhiversen, so hopefully he will get it merged quickly.

https://github.com/Danielhiversen/flux_led/pull/55

rrubin0 commented 6 years ago

that is great news - thanks!

rrubin0 commented 6 years ago

I see some conflicts in the merge, but if you want me to test manually, let me know and I can add/modify what I'm using for custom component "flux_led.py"

oblogic7 commented 6 years ago

I'm trying to track down why the change is causing the tests to fail on the library. Feel free to test it out and verify if it works for you.

rrubin0 commented 5 years ago

Since the commit was to main.py I'm not sure how to use that for testing in the state it is in ... Can you make a "flux_led.py" file for me with these changes that I can test as a custom component, perhaps?

oblogic7 commented 5 years ago

The change can't be made in a custom component since it is in the library that is used by the component.

btreecat commented 5 years ago

I have a different solution to this.

I edited my flux_led.py file to look like this.

# handle RGBW mode
elif self._mode == MODE_RGBW:
    #check if setting warm white or rgb value
    if 'white_value' in kwargs.keys():
        self._bulb.setWarmWhite255(white)
    else:
        self._bulb.setRgbw(*tuple(rgb), brightness=brightness)
rrubin0 commented 5 years ago

I‘d like to test that... On which version of home assistant did you edit flux_led.py? Or, do you mind sharing your file?

btreecat commented 5 years ago

I just updated to the latest package via pip this weekend. So it should be the currently released version.

EDIT version 0.79.3

rrubin0 commented 5 years ago

@btreecat I tested on the bulb; the white values work (selecting 'warm' and 'warm dim' in my setup) but the color picker does not, nor am i able to call colors from my input select list. Closer! but not quite a valid fix, I'm afraid. I'm still on 78.3 but see there has been no updates to the code in the last 2 months, so we are using the same flux_led.py file.

For reference, here are the errors:

2018-10-13 22:35:14 INFO (MainThread) [homeassistant.components.automation] Executing RGB Red
2018-10-13 22:35:14 INFO (MainThread) [homeassistant.helpers.script] Script RGB Red: Running script
2018-10-13 22:35:14 INFO (MainThread) [homeassistant.helpers.script] Script RGB Red: Executing step call service
2018-10-13 22:35:14 ERROR (MainThread) [homeassistant.core] Error executing service <ServiceCall light.turn_on (c:def964ce05fe4c21b6ff434ce0a8245b): entity_id=['light.office_desk_lamp'], brightness=255, rgb_color=(255, 0, 0)>
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/core.py", line 1127, in _event_to_service_call
    await service_handler.func(service_call)
  File "/usr/src/app/homeassistant/components/light/__init__.py", line 355, in async_handle_light_on_service
    await light.async_turn_on(**pars)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/light/flux_led.py", line 273, in turn_on
    self._bulb.setRgbw(*tuple(rgb), w=white, brightness=brightness)
  File "/usr/local/lib/python3.6/site-packages/flux_led/__main__.py", line 868, in setRgbw
    raise Exception
Exception
btreecat commented 5 years ago

Have you tried changing color with just the flux_led Python library the home assistant component is based on?

See if you can use it to change your rgb values from the command line.

Also what did your setrgbw call look like, did you only pass the rgb values and brightness?

-- Stephen Tanner Part 107 Certified Drone Pilot Web, Research, and Cloud Application Developer Virginia Tech Transportation Institute https://TannAir.com https://StephenTanner.com

On Sun, Oct 14, 2018, 01:38 Rick Rubino notifications@github.com wrote:

@btreecat https://github.com/btreecat I tested on the bulb; the white values work (selecting 'warm' and 'warm dim' in my setup) but the color picker does not, nor am i able to call colors from my input select list. Closer! but not quite a valid fix, I'm afraid. I'm still on 78.3 but see there has been no updates to the code in the last 2 months, so we are using the same flux_led.py file.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/home-assistant/home-assistant/issues/15566#issuecomment-429598273, or mute the thread https://github.com/notifications/unsubscribe-auth/AAO3HCFV1hQw8MuQgglev5KsMM8QkMFLks5uks3dgaJpZM4VXfBB .

rrubin0 commented 5 years ago

That was my original issue ...bulb would not respond to color picker or list actions.

I did notice that if I turned the bulb off at the switch after selecting a color it would change to the selected color upon turning the switch back on.

I have not specifically tried testing it again, as the file does not appear to have changed since the last test. I’ll do this after upgrading to 0.79.x or 0.80.x (planning to do soon) and report back

btreecat commented 5 years ago

But have you tested the underlying library directly?

If the underlying library isn't working right then there isn't a way to fix it in home assistant.

Did you change the line for the setRGBW?

-- Stephen Tanner Part 107 Certified Drone Pilot Web, Research, and Cloud Application Developer Virginia Tech Transportation Institute https://TannAir.com https://StephenTanner.com

On Tue, Oct 16, 2018, 16:36 Rick Rubino notifications@github.com wrote:

That was my original issue ...bulb would not respond to color picker or list actions.

I did notice that if I turned the bulb off at the switch after selecting a color it would change to the selected color upon turning the switch back on.

I have not specifically tried testing it again, as the file does not appear to have changed since the last test. I’ll do this after upgrading to 0.79.x or 0.80.x (planning to do soon) and report back

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/home-assistant/home-assistant/issues/15566#issuecomment-430390676, or mute the thread https://github.com/notifications/unsubscribe-auth/AAO3HBaFiZQIPyM3vaC9sM0KqhsLJ7Wuks5ulkNFgaJpZM4VXfBB .

rrubin0 commented 5 years ago

I'm unable to test this directly but did test with the native code in 0.80.3 and with the modification recommended above to setRGBW ... the issues persist.

I can say that everything used to work just fine before 0.73.1. The flux_led.py file from 0.72.1 also works fine too and that is what I'm using for now as a custom component.

log using 0.80.3:

2018-10-20 00:10:05 ERROR (MainThread) [homeassistant.core] Error executing service <ServiceCall light.turn_on (c:3cb4fd73258e45f588abf879cb9ff04b): entity_id=['light.office_desk_lamp'], white_value=255>
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/core.py", line 1177, in _event_to_service_call
    await service_handler.func(service_call)
  File "/usr/src/app/homeassistant/components/light/__init__.py", line 270, in async_handle_light_on_service
    await light.async_turn_on(**pars)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/light/flux_led.py", line 269, in turn_on
    self._bulb.setRgbw(*tuple(rgb), w=white, brightness=brightness)
  File "/usr/local/lib/python3.6/site-packages/flux_led/__main__.py", line 868, in setRgbw
    raise Exception
oblogic7 commented 5 years ago

Hey guys, sorry for the lack of response. Been pretty busy lately. Wife is working this weekend, so finally had some time to look into this while my girls are napping.

I was able to update the tests on the flux library, so that PR should be merged soon. When that happens, we will be able to bump the library version so the changes will be available in HA. I'm confident that this will correct the behavior that is being reported here. I have tested on the bulb that @rrubin0 linked above and it is behaving exactly the same as the other two magic home controllers that I have.

rrubin0 commented 5 years ago

That is good news! Thanks for taking the time to troubleshoot! I'll test once released and report back

rrubin0 commented 5 years ago

I upgraded to 0.81.2 and removed my custom component entry, deleted the py_cache folder and restarted HA ... I'm getting the same bad result - unable to do anything with the flux bulb except on/off/effects.

side note - my wifi strip controllers are now unresponsive too... Control via the Flux phone app is flawless. I'll add back my old custom code and retry

rrubin0 commented 5 years ago

Confirm ... working now with old code once again ... I do notice that the white value setting is removed in this older version; not sure if that matters tho, the bulb is working as RGBW via my input_selections and the native flux app, whereas I barely have on/off control with the updated code.

btreecat commented 5 years ago

Fix is also not working for me either.

I'll clone the latest copy of the flux_led library and do some more testing of the method calls.

-- Stephen Tanner Part 107 Certified Drone Pilot Web, Research, and Cloud Application Developer Virginia Tech Transportation Institute https://TannAir.com https://StephenTanner.com

On Wed, Oct 31, 2018, 01:38 Rick Rubino <notifications@github.com wrote:

Confirm ... working now with old code once again ... I do notice that the white value setting is removed in this older version; not sure if that matters tho, the bulb is working as RGBW via my input_selections and the native flux app, whereas I barely have on/off control with the updated code.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/home-assistant/home-assistant/issues/15566#issuecomment-434567405, or mute the thread https://github.com/notifications/unsubscribe-auth/AAO3HI-p-cU_ZW2hGNn8S5BvJmBJktP2ks5uqTdngaJpZM4VXfBB .

oblogic7 commented 5 years ago

Thanks for the reports guys.

@rrubin0 I was able to reproduce the unresponsive strip controller issue on this controller. Seems that it is not correctly detecting that it is RGBW capable. I need to dig further but specifying mode: 'RGBW' in the config makes it work for me.

Regarding the issue of getting the same bad result, do you mean you are still seeing this error? If not that, can you describe what you are seeing or how you are trying to control the light (GUI, service calls, etc)?

@btreecat Thanks for diving in. Curious to see what you find as well. Be sure to try setting mode: 'RGBW' for the devices that aren't working to see if it changes the behavior.