Core: Yeelight integration broken in 0.116.1

Created on 8 Oct 2020  Â·  43Comments  Â·  Source: home-assistant/core

The problem


Got this error after docker updated today, Yeelight light bulbs do not connect.

 File "/usr/src/homeassistant/homeassistant/components/yeelight/light.py", line 140, in <module>
    EFFECT_RANDOM_LOOP: yee_transitions.randomloop,
AttributeError: module 'yeelight.transitions' has no attribute 'randomloop'

Environment

  • Home Assistant Core release with the issue: 0.116.1
  • Last working Home Assistant Core release (if known): 0.116.0
  • Operating environment (OS/Container/Supervised/Core): homeassistant/home-assistant docker
  • Integration causing this issue: Yeelight
  • Link to integration documentation on our website: https://www.home-assistant.io/integrations/yeelight/

Problem-relevant configuration.yaml

yeelight: !include yeelights.yaml
devices:
  192.168.x.x:
    name: Kitchen light bulb
    model: color2
  192.168.x.x:
    name: Living room light bulb 1
    model: color2
  192.168.x.x:
    name: Living room light bulb 2
    model: color2
  192.168.x.x:
    name: Living room light bulb 3
    model: color2
  192.168.x.x:
    name: Desk light bulb
    model: color2

Traceback/Error logs

2020-10-08 19:07:43 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant.
2020-10-08 19:07:45 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Living room light bulb 3 for light
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 231, in async_setup
    result = await component.async_setup_entry(hass, self)  # type: ignore
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 287, in async_setup_entry
    return await hass.data[DOMAIN].async_setup_entry(entry)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 140, in async_setup_entry
    platform = await async_prepare_setup_platform(
  File "/usr/src/homeassistant/homeassistant/setup.py", line 298, in async_prepare_setup_platform
    platform = integration.get_platform(domain)
  File "/usr/src/homeassistant/homeassistant/loader.py", line 401, in get_platform
    cache[full_name] = importlib.import_module(
  File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/src/homeassistant/homeassistant/components/yeelight/light.py", line 140, in <module>
    EFFECT_RANDOM_LOOP: yee_transitions.randomloop,
AttributeError: module 'yeelight.transitions' has no attribute 'randomloop'
2020-10-08 19:07:45 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Living room light bulb 1 for light
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 231, in async_setup
    result = await component.async_setup_entry(hass, self)  # type: ignore
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 287, in async_setup_entry
    return await hass.data[DOMAIN].async_setup_entry(entry)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 140, in async_setup_entry
    platform = await async_prepare_setup_platform(
  File "/usr/src/homeassistant/homeassistant/setup.py", line 298, in async_prepare_setup_platform
    platform = integration.get_platform(domain)
  File "/usr/src/homeassistant/homeassistant/loader.py", line 401, in get_platform
    cache[full_name] = importlib.import_module(
  File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/src/homeassistant/homeassistant/components/yeelight/light.py", line 140, in <module>
    EFFECT_RANDOM_LOOP: yee_transitions.randomloop,
AttributeError: module 'yeelight.transitions' has no attribute 'randomloop'
2020-10-08 19:07:45 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Kitchen light bulb for light
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 231, in async_setup
    result = await component.async_setup_entry(hass, self)  # type: ignore
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 287, in async_setup_entry
    return await hass.data[DOMAIN].async_setup_entry(entry)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 140, in async_setup_entry
    platform = await async_prepare_setup_platform(
  File "/usr/src/homeassistant/homeassistant/setup.py", line 298, in async_prepare_setup_platform
    platform = integration.get_platform(domain)
  File "/usr/src/homeassistant/homeassistant/loader.py", line 401, in get_platform
    cache[full_name] = importlib.import_module(
  File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/src/homeassistant/homeassistant/components/yeelight/light.py", line 140, in <module>
    EFFECT_RANDOM_LOOP: yee_transitions.randomloop,
AttributeError: module 'yeelight.transitions' has no attribute 'randomloop'
2020-10-08 19:07:45 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Living room light bulb 2 for light
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 231, in async_setup
    result = await component.async_setup_entry(hass, self)  # type: ignore
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 287, in async_setup_entry
    return await hass.data[DOMAIN].async_setup_entry(entry)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 140, in async_setup_entry
    platform = await async_prepare_setup_platform(
  File "/usr/src/homeassistant/homeassistant/setup.py", line 298, in async_prepare_setup_platform
    platform = integration.get_platform(domain)
  File "/usr/src/homeassistant/homeassistant/loader.py", line 401, in get_platform
    cache[full_name] = importlib.import_module(
  File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/src/homeassistant/homeassistant/components/yeelight/light.py", line 140, in <module>
    EFFECT_RANDOM_LOOP: yee_transitions.randomloop,
AttributeError: module 'yeelight.transitions' has no attribute 'randomloop'
2020-10-08 19:07:45 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Desk light bulb for light
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 231, in async_setup
    result = await component.async_setup_entry(hass, self)  # type: ignore
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 287, in async_setup_entry
    return await hass.data[DOMAIN].async_setup_entry(entry)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 140, in async_setup_entry
    platform = await async_prepare_setup_platform(
  File "/usr/src/homeassistant/homeassistant/setup.py", line 298, in async_prepare_setup_platform
    platform = integration.get_platform(domain)
  File "/usr/src/homeassistant/homeassistant/loader.py", line 401, in get_platform
    cache[full_name] = importlib.import_module(
  File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/src/homeassistant/homeassistant/components/yeelight/light.py", line 140, in <module>
    EFFECT_RANDOM_LOOP: yee_transitions.randomloop,
AttributeError: module 'yeelight.transitions' has no attribute 'randomloop'

Additional information

yeelight

Most helpful comment

Sorry guys, I released 0.5.4 to include a file that was missing in 0.5.3 and flit must have reuploaded an old built version. randomloop was renamed to random_loop for consistency.

I have yanked the offending file, this should now be resolved without you having to do anything else.

All 43 comments

Same problem here, rolling back to previous version restores normal behavior

Seeing the same issue here.

The same is here.

Same problem here, just after upgrading from python 3.7.3 to python 3.8.6 and installing version 0.116.1 of homeassistant.

As I don't use the EFFECT_RANDOM_LOOP, as a quick workaround I just commented line 140 in /srv/homeassistant/lib/python3.8/site-packages/homeassistant/components/yeelight/light.py and restarted home assistant.

Same here. 0.116.1 broke yeelight. I use discovery.

Same here

Same here
Restored the snapshot that I had done just right before upgrading.

I've also lost all Yeelight with 0.116.1

eg.

2020-10-09 07:49:29 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Downstairs for light
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 231, in async_setup
    result = await component.async_setup_entry(hass, self)  # type: ignore
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 287, in async_setup_entry
    return await hass.data[DOMAIN].async_setup_entry(entry)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 140, in async_setup_entry
    platform = await async_prepare_setup_platform(
  File "/usr/src/homeassistant/homeassistant/setup.py", line 298, in async_prepare_setup_platform
    platform = integration.get_platform(domain)
  File "/usr/src/homeassistant/homeassistant/loader.py", line 401, in get_platform
    cache[full_name] = importlib.import_module(
  File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/src/homeassistant/homeassistant/components/yeelight/light.py", line 140, in <module>
    EFFECT_RANDOM_LOOP: yee_transitions.randomloop,
AttributeError: module 'yeelight.transitions' has no attribute 'randomloop'

Rip Yeelight

Same here after update from 0.115.6 to 0.116.1 :(

Please upvote the original issue instead of saying that you have the same issue, thanks 😊

yeelight documentation
yeelight source
(message by IssueLinks)

Hey there @rytilahti, @zewelor, @shenxn, mind taking a look at this issue as its been labeled with an integration (yeelight) you are listed as a codeowner for? Thanks!
(message by CodeOwnersMention)

as a quick workaround I just commented line 140 in /srv/homeassistant/lib/python3.8/site-packages/homeassistant/components/yeelight/light.py and restarted home assistant.

I can confirm this works.

Same problem here, just after upgrading from python 3.7.3 to python 3.8.6 and installing version 0.116.1 of homeassistant.

As I don't use the EFFECT_RANDOM_LOOP, as a quick workaround I just commented line 140 in /srv/homeassistant/lib/python3.8/site-packages/homeassistant/components/yeelight/light.py and restarted home assistant.

sorry to go a little bit offtopic, but in my container /srv is empty ... where can find that ?

-- EDIT
i think i found it in : /usr/src/homeassistant/homeassistant/components/yeelight/light.py

It looks like the name is wrong, but it hasn't changed in 0.116.1

diff --git a/homeassistant/components/yeelight/light.py b/homeassistant/components/yeelight/light.py
index a84ebebf6e..93dbc5bcb0 100644
--- a/homeassistant/components/yeelight/light.py
+++ b/homeassistant/components/yeelight/light.py
@@ -137,7 +137,7 @@ EFFECTS_MAP = {
     EFFECT_POLICE2: yee_transitions.police2,
     EFFECT_CHRISTMAS: yee_transitions.christmas,
     EFFECT_RGB: yee_transitions.rgb,
-    EFFECT_RANDOM_LOOP: yee_transitions.randomloop,
+    EFFECT_RANDOM_LOOP: yee_transitions.random_loop,
     EFFECT_LSD: yee_transitions.lsd,
     EFFECT_SLOWDOWN: yee_transitions.slowdown,
 }
@@ -661,7 +661,7 @@ class YeelightGenericLight(YeelightEntity, LightEntity):
         elif effect in EFFECTS_MAP:
             flow = Flow(count=0, transitions=EFFECTS_MAP[effect]())
         elif effect == EFFECT_FAST_RANDOM_LOOP:
-            flow = Flow(count=0, transitions=yee_transitions.randomloop(duration=250))
+            flow = Flow(count=0, transitions=yee_transitions.random_loop(duration=250))
         elif effect == EFFECT_WHATSAPP:
             flow = Flow(count=2, transitions=yee_transitions.pulse(37, 211, 102))
         elif effect == EFFECT_FACEBOOK:

The library uses random_loop but the home assistant code references randomloop. The patch I posted above may resolve the issue, however I'm not able to test it as I won't be back to a place with yeelights until next month.

OK so I edited light.py and restarted and all good. Thanks Nick.

Hi ,
I'm not able to access the light.py neither on :
/usr/src/homeassistant/homeassistant/components/yeelight/light.py
or
/srv/homeassistant/lib/python3.8/site-packages/homeassistant/components/yeelight/light.py
how can i check where the light.py file is ?
in my error log do mentions the /usr/src/homeassistant/homeassistant/components/yeelight/light.py line 140 .. but the folder src dont let me in ...
help appreciated

you need to docker exec into the container

Ok but don't know how to do that. In the meanwhile, copied the component from github.homeassistant and created a costume component with the light.py edited. It's now working fine. Will remove the custom component as soon as this is fixed. Thanks you for the prompt support and for sure will check documentation on how to docker exec

yeah that's way easier probably... good choice.

Ok but don't know how to do that. In the meanwhile, copied the component from github.homeassistant and created a costume component with the light.py edited. It's now working fine. Will remove the custom component as soon as this is fixed. Thanks you for the prompt support and for sure will check documentation on how to docker exec

Can you tell me how you did it? (The patch will probably be released before I will have time to do it, so it's not that important)

@bdraco yes, the Yeelight library has changed in July. I don't know what could be a safe solution for issues like this, as it could happen after any library upgrade.

Changed in July but not an issue till October?

Yes, this is strange. There are no errors in HA 0.115.x and 0.160.0 with yeelight 0.5.3 library.

Yeelight libraray was upgraded just yesterday to 0.5.4, that must be the reason (even though the commit is from July, probably it was not merged into master branch until yesterday)

The function randomloop was renamed to random_loop in python-yeelight library in commit https://gitlab.com/stavros/python-yeelight/-/commit/78632f8e8f652df67010524fb4bbd7ea6990da85

And this commit first appeared in release 0.5.4 of this library (released at Oct, 8 2020)

But I don't understand how that version was added to Home Assistant. As far as I see in Home Assistant 0.116.1 there is explicitly stated that the version 0.5.3 of the libary should be used — https://github.com/home-assistant/core/blob/0.116.1/requirements_all.txt#L2298

There is random_loop not randomloop in yeelight 0.5.3 installed via pypi.

So the change was actually released in 0.5.3 and we bumped to that version here (#39542), which is released in 0.115.0. There seems to be a CI problem. Otherwise #39542 won't pass all tests. Tests should be sufficient to prevent problems like this if everything works as expected.

$ docker run -it homeassistant/raspberrypi3-homeassistant:0.116.0 cat /usr/local/lib/python3.8/site-packages/yeelight/transitions.py|grep 'def random'
def randomloop(duration=750, brightness=100, count=9):

$ docker run -it homeassistant/raspberrypi3-homeassistant:0.116.1 cat /usr/local/lib/python3.8/site-packages/yeelight/transitions.py|grep 'def random'
def random_loop(duration=750, brightness=100, count=9):
$ docker run -it homeassistant/raspberrypi3-homeassistant:0.116.0 cat /usr/src/homeassistant/requirements_all.txt|grep yeelight==
yeelight==0.5.3
$ docker run -it homeassistant/raspberrypi3-homeassistant:0.116.1 cat /usr/src/homeassistant/requirements_all.txt|grep yeelight==
yeelight==0.5.3

The only way I can explain this is that the package yeelight version 0.5.3 was re-uploaded to pypi with incorrect version.

On my HA 0.116 the yeellight library is at version 0.5.3 and there is a randomloop in it.

re-uploaded to pypi

Is it possible? I think when you want reupload package you have to change version.

I'm not sure.

But this looks strange:

https://pypi.org/project/yeelight/0.5.3/#files

1

Yes, the file was uploaded twice under different names. It's possible.

I have created an issue in yeelight library repo — https://gitlab.com/stavros/python-yeelight/-/issues/56

Sorry guys, I released 0.5.4 to include a file that was missing in 0.5.3 and flit must have reuploaded an old built version. randomloop was renamed to random_loop for consistency.

I have yanked the offending file, this should now be resolved without you having to do anything else.

I have yanked the offending file, this should now be resolved without you having to do anything else.

Thank you!

I'm afraid that the things are a bit more complicated. There are already builds (docker images) that have the unexpected code. I'm not sure that it is worth rebuliding them.

All the new builds based on yeelight==0.5.3 should be fine now, and after releasing https://github.com/home-assistant/core/pull/41524 the new version of Home Assistant will be fixed.

Oh hm, I think those builds can't be helped now, though, they're already frozen. Other than those, new installations/etc should work fine. Is there anything else we can do?

As I understand the situation, everything is solved. The code with fix is ready, tested and merged and we are just waiting for the Home Assistant release 0.116.2.

we are just waiting for the Home Assistant release 0.116.2.

We also need tag 0.116.2 for this PR.

OK, we have the tag already.

Ok but don't know how to do that. In the meanwhile, copied the component from github.homeassistant and created a costume component with the light.py edited. It's now working fine. Will remove the custom component as soon as this is fixed. Thanks you for the prompt support and for sure will check documentation on how to docker exec

Can you tell me how you did it? (The patch will probably be released before I will have time to do it, so it's not that important)

Its just a matter of copy the component folder from homeassistant github into your custom_component and correct the file light.py
In the meanwhile 0.116.2 is now live but it's not ok on my side. I revert to using my custom_comnent edit and corrected

Was this page helpful?
0 / 5 - 0 ratings

Related issues

i-am-shodan picture i-am-shodan  Â·  3Comments

flsabourin picture flsabourin  Â·  3Comments

kirichkov picture kirichkov  Â·  3Comments

sh0rez picture sh0rez  Â·  3Comments

ofuangka picture ofuangka  Â·  3Comments