Node Red Error: unable to import component

Hi,

I have an error with Node Red. It’s not effecting any of my flows as far as I know, but I get the error everyday.

Any clue how to solve it?

Logger: homeassistant.setup
Source: setup.py:322
First occurred: 10:46:45 (1 occurrences)
Last logged: 10:46:45

Setup failed for custom integration 'nodered': Unable to import component: cannot import name '_get_agent_manager' from 'homeassistant.components.conversation' (/usr/src/homeassistant/homeassistant/components/conversation/__init__.py)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1007, in async_get_component
    comp = await self.hass.async_add_import_executor_job(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1067, in _get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/loop.py", line 200, in protected_loop_func
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, 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 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/config/custom_components/nodered/__init__.py", line 58, in <module>
    from .websocket import register_websocket_handlers
  File "/config/custom_components/nodered/websocket.py", line 8, in <module>
    from homeassistant.components.conversation import (
ImportError: cannot import name '_get_agent_manager' from 'homeassistant.components.conversation' (/usr/src/homeassistant/homeassistant/components/conversation/__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 322, in _async_setup_component
    component = await integration.async_get_component()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1027, in async_get_component
    self._component_future.result()
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1019, in async_get_component
    comp = self._get_component()
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1067, in _get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/loop.py", line 200, in protected_loop_func
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, 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 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/config/custom_components/nodered/__init__.py", line 58, in <module>
    from .websocket import register_websocket_handlers
  File "/config/custom_components/nodered/websocket.py", line 8, in <module>
    from homeassistant.components.conversation import (
ImportError: cannot import name '_get_agent_manager' from 'homeassistant.components.conversation' (/usr/src/homeassistant/homeassistant/components/conversation/__init__.py)

Previous posting about this error message, and solution, can be found at

https://community.home-assistant.io/t/node-red-error-after-updating-homeassistant-to-version-2024-5-0/724520

Thanks.

I always forget updating via HACS. Is there a way to show how much updates are pending in HACS on the dashboard?

I don’t use HACS (so I can’t answer your question directly) and I do all my updates manually, which is a little tedious but probably a ‘good thing’ as (for example) auto update of just Node-RED Addon has given rise to breaking changes recently.

For myself, I update HA core and supervisor, manually about half a month behind the release (gives time to listen out for ‘issues’).

Node-RED I update as a group, driven by whatever has been recently released, and is a significant enough change:

  • first cross checking what Node-RED is up to (the latest releases as v4+ has significant changes to how JSONata is called).
  • then checking the Node-RED Addon releases for breaking changes and dependences (on HA) and the version of Node-RED and the version of HA WebSocket nodes included.
  • then checking the HA WebSocket nodes releases to see how the latest matches with what the Addon requires, and looking for breaking changes or dependencies (on HA, on Node-RED)
  • finally checking the Node-RED Companion integration releases.

It would be nice if there was a simple cascade of dependences, perhaps

Addon ← HA
Addon → Node-RED, WebSocket

WebSocket ← Node-RED, HA
Companion ← HA, WebSocket

however I have yet to work out a reliable model, or a way to automate a reporting tool to suggest a) an update is available and b) what the impact of updating in isolation is

At the moment, externally forced change comes from HA (eg changing the way service calls are called and return values), and from Node-RED (eg changing the way JSONata expressions are called with a callback). Since Kermit updates the WebSocket nodes based on HA and NR changes (as well as his tireless ongoing development), these node updates are likely to be first, but for users of the Addon the packaged Node-RED & WebSocket nodes are tested and bundled together, and thus an update to the Addon must be done inline with the current HA versions.

The Companion sits out on a limb I think, in that this is updated based on breaking changes in HA perhaps more than anything else. Your posted error issue is highlighted in release v4.0.0 regarding the conversation agent, but it is not as simple as just keeping the Companion up to date with the latest release, as the companion must match HA, and also the WebSocket nodes, and the WebSocket nodes must match HA and Node-RED, but are bundled in to the Addon, which with NR and the WebSocket nodes must match the Companion.

At this point I feel that I am going around in a circle, but suggestions are:

  • always regard updating HA / Node-RED Addon (Node-RED if not as Addon) / WebSocket Nodes (manually above Addon bundle) / HA NR Companion as a ‘set
  • always update manually and not automatically
  • always check breaking changes before updating
  • always check dependencies that may necessitate an additional update

This is as far as I have ever got with a suggestions for ‘automating’ the Node-RED update state model

update relationship diagram for HA Node-RED users

Perhaps someone would like to make this a reality?

What version of HA are you running? All hacs updates show where the system/core updates are shown when available. Go to integrations and look for hacs. Click on it, there should be entities for all your installed hacs integrations.

Hi, that’s nice. I didn’t know that.

Is there a way to get a sum of the pending updates to show on my start screen. Then I can link that to a view with all specific entities.

Something like “3 addons pending updates” or so.

The HACS integration has an entity sensor.hacs that shows that info.