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

@service decorator with services_name causes HA >= 2023.8.1 to fail #525

Open
redlefloh opened this issue Sep 11, 2023 · 2 comments
Open

Comments

@redlefloh
Copy link

I had issues starting with HA 2023.8.1 that HA would not start and would issue an error message (see also here and here):

2023-08-27 16:11:49.172 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [548237125696] Error handling message: Unknown error (unknown_error) Display Panel from 192.168.2.100 (Mozilla/5.0 (X11; CrOS aarch64 13597.84.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.5672.95 Safari/537.36)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 26, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 417, in handle_get_services
    payload = await _async_get_all_descriptions_json(hass)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 398, in _async_get_all_descriptions_json
    descriptions = await async_get_all_descriptions(hass)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 612, in async_get_all_descriptions
    translations = await translation.async_get_translations(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/translation.py", line 318, in async_get_translations
    cached = await cache.async_fetch(language, category, components)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/translation.py", line 209, in async_fetch
    await self._async_load(language, components_to_load)
  File "/usr/src/homeassistant/homeassistant/helpers/translation.py", line 230, in _async_load
    raise int_or_exc
homeassistant.loader.IntegrationNotFound: Integration 'mennekes' not found.

I could not find anything referring to such an integration in e.g. config/custom_components, or in HACS as a REST sensor, or in any other place that I was looking at. But now after a lot of debugging and (soul) searching, I finally found the root cause of this!

It is actually caused by pyscript (the one custom integration I cannot live without!). I had specified a service_name with DOMAIN.SERVICE in an @service decorator, e.g.: #@service("mennekes.get_charge_mode") which is explicitly allowed by the pyscript documentation (see here) and this actually made it possible to call this function with DOMAIN.SERVICE (i.e. with mennekes.get_charge_mode) from within HA, and this also always worked just fine until 2023.8.1 launched.

Starting with HA >= 2023.8.1, HA seems to identify such a DOMAIN in a service_name in a pyscript @service decorator as a new "integration" and since it can't find a translation for that new "integration", it then fails with the error message above and HA actually does not load anymore after that.

I now removed all these service decorators in pyscript (I also had some with the DOMAIN "studer" and therefore HA also sometimes failed because it could not find the integration "studer", and after I removed all these service decorators, HA >= 2023.8.1 is loading just fine again for me.

I am not sure if this should/can be resolved in pyscript or should/can be resolved in HA, but it definitely was a hard to debug issue that other HA/pyscript users may run into as well so it would be great to find a fix for this. Thanks!

@redlefloh
Copy link
Author

I have also added some more context in the post here

@craigbarratt
Copy link
Member

This is a duplicate of #517.

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