core icon indicating copy to clipboard operation
core copied to clipboard

Roborock integration not loading on 2025.5.0b4

Open SeanPM5 opened this issue 7 months ago • 18 comments

The problem

After updating to 2025.5.0b4 the Roborock integration is not loading for me (b3 worked fine).

Image
Logger: homeassistant.util.loop
Source: util/loop.py:77
First occurred: 3:52:30 PM (1 occurrence)
Last logged: 3:52:30 PM

Detected blocking call to import_module with args ('homeassistant.components.roborock',) in /usr/src/homeassistant/homeassistant/loader.py, line 1053: ComponentProtocol, importlib.import_module(self.pkg_path) inside the event loop; This is causing stability issues. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#import_module Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/__main__.py", line 227, in <module> sys.exit(main()) File "/usr/src/homeassistant/homeassistant/__main__.py", line 213, in main exit_code = runner.run(runtime_conf) File "/usr/src/homeassistant/homeassistant/runner.py", line 154, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.13/asyncio/base_events.py", line 712, in run_until_complete self.run_forever() File "/usr/local/lib/python3.13/asyncio/base_events.py", line 683, in run_forever self._run_once() File "/usr/local/lib/python3.13/asyncio/base_events.py", line 2040, in _run_once handle._run() File "/usr/local/lib/python3.13/asyncio/events.py", line 89, in _run self._context.run(self._callback, *self._args) File "/usr/src/homeassistant/homeassistant/setup.py", line 171, in async_setup_component result = await _async_setup_component(hass, domain, config) File "/usr/src/homeassistant/homeassistant/setup.py", line 344, in _async_setup_component component = await integration.async_get_component() File "/usr/src/homeassistant/homeassistant/loader.py", line 1005, in async_get_component comp = self._get_component() File "/usr/src/homeassistant/homeassistant/loader.py", line 1053, in _get_component ComponentProtocol, importlib.import_module(self.pkg_path)

Also in logs:

Logger: homeassistant.setup
Source: setup.py:344
First occurred: 3:52:30 PM (1 occurrence)
Last logged: 3:52:30 PM

Setup failed for 'roborock': Unable to import component: cannot import name 'Rate' from 'pyrate_limiter' (/usr/local/lib/python3.13/site-packages/pyrate_limiter/__init__.py)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 993, in async_get_component
    comp = await self.hass.async_add_import_executor_job(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        self._get_component, True
        ^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1053, in _get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/loop.py", line 201, in protected_loop_func
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.13/importlib/__init__.py", line 88, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 1026, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/usr/src/homeassistant/homeassistant/components/roborock/__init__.py", line 21, in <module>
    from roborock.web_api import RoborockApiClient
  File "/usr/local/lib/python3.13/site-packages/roborock/web_api.py", line 13, in <module>
    from pyrate_limiter import BucketFullException, Duration, Limiter, Rate
ImportError: cannot import name 'Rate' from 'pyrate_limiter' (/usr/local/lib/python3.13/site-packages/pyrate_limiter/__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 344, in _async_setup_component
    component = await integration.async_get_component()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1013, in async_get_component
    self._component_future.result()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1005, in async_get_component
    comp = self._get_component()
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1053, in _get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/loop.py", line 201, in protected_loop_func
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.13/importlib/__init__.py", line 88, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 1026, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/usr/src/homeassistant/homeassistant/components/roborock/__init__.py", line 21, in <module>
    from roborock.web_api import RoborockApiClient
  File "/usr/local/lib/python3.13/site-packages/roborock/web_api.py", line 13, in <module>
    from pyrate_limiter import BucketFullException, Duration, Limiter, Rate
ImportError: cannot import name 'Rate' from 'pyrate_limiter' (/usr/local/lib/python3.13/site-packages/pyrate_limiter/__init__.py)

What version of Home Assistant Core has the issue?

2025.5.0b4

What was the last working version of Home Assistant Core?

2025.5.0b3

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Roborock

Link to integration documentation on our website

https://www.home-assistant.io/integrations/roborock/

Diagnostics information

No response

Example YAML snippet


Anything in the logs that might be useful for us?


Additional information

Was working fine in previous beta only started with b4. One vacuum is an S4 Max, other is an S6.

roborock.vacuum.a19 roborock.vacuum.s6 (roborock.vacuum.s6)

SeanPM5 avatar May 06 '25 00:05 SeanPM5

Hey there @lash-l, @allenporter, mind taking a look at this issue as it has been labeled with an integration (roborock) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of roborock can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign roborock Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


roborock documentation roborock source (message by IssueLinks)

home-assistant[bot] avatar May 06 '25 00:05 home-assistant[bot]

Please upload your diagnostics - it is likely that another integration or custom integration is pinning to the wrong version of pyrate_limiter

Lash-L avatar May 06 '25 00:05 Lash-L

There's no option to enable debug logging or download integration diagnostics because the integration doesn't load at all.

I restarted in safe mode though and Roborock is still not loading, which rules out custom integrations. It must be another core integration interfering. Not sure how to pinpoint further besides sharing my integration list from safe mode:

Image Image

SeanPM5 avatar May 06 '25 01:05 SeanPM5

Can you ssh into your HA instance, docker exec into your HA container(ie docker container ps then find your HA instance( and then docker exec -it your_container_id sh), then run pip show pyrate_limiter? I did a full install from my terminal and nothing is pinning me down. cc @allenporter - you may have some better ideas on how to diagnose this

Lash-L avatar May 06 '25 01:05 Lash-L

I already rolled back but before I did I tested by disabling most of the core integrations and also restarting in safe mode. Roborock still did not load, can see here w/ most core integrations disabled + custom integrations not loaded due to safe mode...

Image Image

(After that screenshot I disabled OpenAI conversation, Geofency, Radio Browser too). Since the remaining integrations are local and probably wouldn't be using pyrate_limiter I feel like that probably narrows it down to Ecobee integration (cloud polling) as the likely culprit, but I dunno... Don't have time to diagnose it right now cause I gotta be up early, but hopefully this narrows things down somewhat.

SeanPM5 avatar May 06 '25 03:05 SeanPM5

Putting the integrations in safe mode probably isn't enough to repair this given its not asked for explicitly. Its just going to leave whatever package was installed.

ha core rebuild could also be worth a try...

Maybe we want to add constraint in homeassistant/package_constraints.txt? to v3+ version which i think added this a couple years ago, but not sure the specific version.

allenporter avatar May 06 '25 05:05 allenporter

Adding another datapoint here: Roborock loads just fine here on b5.

on b4, pip show pyrate_limiter gave an empty result, on b5 it shows:

/config # pip show pyrate_limiter
Name: pyrate-limiter
Version: 3.7.0
Summary: Python Rate-Limiter using Leaky-Bucket Algorithm
Home-page: https://github.com/vutran1710/PyrateLimiter
Author: vutr
Author-email: [email protected]
License: MIT
Location: /usr/local/lib/python3.13/site-packages
Requires:
Required-by: python-roborock
/config #

hmmbob avatar May 06 '25 07:05 hmmbob

Updated to b5 real quick and ran the command suggested by Luke above;

/config # pip show pyrate_limiter
Name: pyrate-limiter
Version: 2.10.0
Summary: Python Rate-Limiter using Leaky-Bucket Algorithm
Home-page: https://github.com/vutran1710/PyrateLimiter
Author: vutr
Author-email: [email protected]
License: MIT
Location: /usr/local/lib/python3.13/site-packages
Requires: 
Required-by: python-roborock, requests-ratelimiter

then did:

/config # pip show requests-ratelimiter
Name: requests-ratelimiter
Version: 0.7.0
Summary: Rate-limiting for the requests library
Home-page: https://github.com/JWCook/requests-ratelimiter
Author: Jordan Cook
Author-email: 
License: MIT
Location: /usr/local/lib/python3.13/site-packages
Requires: pyrate-limiter, requests
Required-by: PSNAWP-HA

It's the PlayStation Network integration from @JackJPowell (currently a custom integration, but PR is open for submitting to core). I thought restarting in safe mode would rule out custom integrations but I guess not in this particular case.

Since it's a custom integration this can probably be closed unless there's anything that can be done to avoid the conflict. As mentioned above the Roborock integration only broke after going from beta 3 to beta 4, was working perfectly fine before that. The hass-psn integration it's apparently conflicting with was last updated a month ago.

SeanPM5 avatar May 06 '25 10:05 SeanPM5

Yeah so this issue will be closed as it is for a custom integration

It's a unfortunate conflict and there are three real solutions

  1. update the pyrate dependency for requests-ratelimiter, but this seems to be a blocked issue for that repository: https://github.com/JWCook/requests-ratelimiter/issues/78
  2. PSN package should switch off of requests-ratelimiter and just use pyrate itself. Ideally this repository uses aiohttp instead of requests and that package would be not relevant anyways, but I see that the maintainer of that repo is not the same as the person who is adding the hass integration, so that may be hard.
  3. We bump our version of pyrate_limiter down on Roborock. I would say this is not really a solution and I think is the wrong approach - just want to mention it to give the reasons why it shouldn't be done. As if we bumped our versioning down, then we are now a blocker for other integrations in the future and then they also have to use the old version. Then there ends up being a big backlog of integrations all using a very outdated package.

Unfortunately, before @JackJPowell can get the PSN integration merged as a core integration, this will have to be fixed as it is going to fail the dependency check.

Maybe @allenporter has other opinions though

Lash-L avatar May 06 '25 12:05 Lash-L

I'll bring this up with the maintainer of psnawp and share this thread. He is working with me on another dependency conflict with HA so hopefully we can reach a solution for this too. He has been great to work with so far.

JackJPowell avatar May 06 '25 13:05 JackJPowell

I’ve been experiencing the same issue since upgrading to 2025.5. I was hoping it would be resolved after removing the custom PlayStation Network integration, but there was no change — the Roborock integration still isn’t loading.

Error occurred loading flow for integration roborock: cannot import name 'Rate' from 'pyrate_limiter' (/usr/local/lib/python3.13/site-packages/pyrate_limiter/__init__.py) 
 09:39:06 – (FEHLER) config_entries.py
 Detected blocking call to import_module with args ('homeassistant.components.roborock',) in /usr/src/homeassistant/homeassistant/loader.py, line 1053: ComponentProtocol, importlib.import_module(self.pkg_path) inside the event loop; This is causing stability issues. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#import_module Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/__main__.py", line 227, in <module> sys.exit(main()) File "/usr/src/homeassistant/homeassistant/__main__.py", line 213, in main exit_code = runner.run(runtime_conf) File "/usr/src/homeassistant/homeassistant/runner.py", line 154, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.13/asyncio/base_events.py", line 706, in run_until_complete self.run_forever() File "/usr/local/lib/python3.13/asyncio/base_events.py", line 677, in run_forever self._run_once() File "/usr/local/lib/python3.13/asyncio/base_events.py", line 2034, in _run_once handle._run() File "/usr/local/lib/python3.13/asyncio/events.py", line 89, in _run self._context.run(self._callback, *self._args) File "/usr/src/homeassistant/homeassistant/setup.py", line 171, in async_setup_component result = await _async_setup_component(hass, domain, config) File "/usr/src/homeassistant/homeassistant/setup.py", line 344, in _async_setup_component component = await integration.async_get_component() File "/usr/src/homeassistant/homeassistant/loader.py", line 1005, in async_get_component comp = self._get_component() File "/usr/src/homeassistant/homeassistant/loader.py", line 1053, in _get_component ComponentProtocol, importlib.import_module(self.pkg_path) 
 09:39:06 – (WARNUNG) util/loop.py - Meldung ist erstmals am 09:38:41 aufgetreten und erscheint 2-mal
 Setup failed for 'roborock': Unable to import component: cannot import name 'Rate' from 'pyrate_limiter' (/usr/local/lib/python3.13/site-packages/pyrate_limiter/__init__.py) 
 09:38:41 – (FEHLER) 

ciddi89 avatar May 09 '25 08:05 ciddi89

Updated core to 2025.5 just yesterday and now also roborock integration is not running any more.

Image

For me it looks like it cannot login to my cloud account? I don't know where to look to gather more detail on what's going wrong.

Buuuh avatar May 09 '25 09:05 Buuuh

@Buuuh the symptoms are different than the issue we are discussing here, please open your own issue and fill out the issue template if you suspect there is a bug. thanks!

allenporter avatar May 09 '25 14:05 allenporter

I'll bring this up with the maintainer of psnawp and share this thread. He is working with me on another dependency conflict with HA so hopefully we can reach a solution for this too. He has been great to work with so far.

Any idea on how soon a fix could be pushed? I am missing both of these integrations, I use them quite frequently. 😬

NickVulkers avatar May 10 '25 16:05 NickVulkers

I'll bring this up with the maintainer of psnawp and share this thread. He is working with me on another dependency conflict with HA so hopefully we can reach a solution for this too. He has been great to work with so far.

Any idea on how soon a fix could be pushed? I am missing both of these integrations, I use them quite frequently. 😬

Assuming you're suffering from the original roborock problem I'll hopefully have an update out today that will work around the issue for a little bit longer until the library maintainer updates his end. I planned to have this out sooner but life got in the way.

@NickVulkers Pushed 0.7.5 which should resolve the issue. Give it a shot and let me know if you run into any issues.

JackJPowell avatar May 10 '25 18:05 JackJPowell

Someone can send a CL to add the dependency in homeassistant/package_constraints.txt or the custom component author can update the component to depend on a newer version that is the one home assistant depends on and release an update.

allenporter avatar May 10 '25 19:05 allenporter

@JackJPowell With the PS Network release 0.7.5, everything is working fine again. Thank you very much for the quick fix! ☺️

ciddi89 avatar May 10 '25 21:05 ciddi89

I'll bring this up with the maintainer of psnawp and share this thread. He is working with me on another dependency conflict with HA so hopefully we can reach a solution for this too. He has been great to work with so far.

Any idea on how soon a fix could be pushed? I am missing both of these integrations, I use them quite frequently. 😬

Assuming you're suffering from the original roborock problem I'll hopefully have an update out today that will work around the issue for a little bit longer until the library maintainer updates his end. I planned to have this out sooner but life got in the way.

@NickVulkers Pushed 0.7.5 which should resolve the issue. Give it a shot and let me know if you run into any issues.

@JackJPowell This resolved my errors, thanks for the quick response!

NickVulkers avatar May 11 '25 09:05 NickVulkers