Home Assistant 2024.11 **BETA**: "Cannot import name 'Config' from 'homeassistant.core'"
Closed this issue · 9 comments
Configuration
Bermuda is not being loaded, so I cannot access it's configurations.
Describe the bug
When Home Assistant 2024.11.0b0 is installed, Bermuda (between a few other integrations) is listed on notifications as with an error and not loaded.
The following error messages are available on the log:
Logger: homeassistant.setup
Source: setup.py:334
First occurred: 03:03:59 (1 occurrences)
Last logged: 03:03:59
Setup failed for custom integration 'bermuda': Unable to import component: cannot import name 'Config' from 'homeassistant.core' (/usr/src/homeassistant/homeassistant/core.py)
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/loader.py", line 1011, 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 1071, 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/bermuda/__init__.py", line 11, in <module>
from homeassistant.core import Config
ImportError: cannot import name 'Config' from 'homeassistant.core' (/usr/src/homeassistant/homeassistant/core.py). Did you mean: 'config'?
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/setup.py", line 334, in _async_setup_component
component = await integration.async_get_component()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/loader.py", line 1031, in async_get_component
self._component_future.result()
File "/usr/src/homeassistant/homeassistant/loader.py", line 1023, in async_get_component
comp = self._get_component()
^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/loader.py", line 1071, 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/bermuda/__init__.py", line 11, in <module>
from homeassistant.core import Config
ImportError: cannot import name 'Config' from 'homeassistant.core' (/usr/src/homeassistant/homeassistant/core.py). Did you mean: 'config'?
Logger: homeassistant.util.loop
Source: util/loop.py:77
First occurred: 03:03:59 (2 occurrences)
Last logged: 03:09:40
Detected blocking call to import_module with args ('custom_components.bermuda',) in /usr/src/homeassistant/homeassistant/loader.py, line 1071: 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 223, in <module> sys.exit(main()) File "/usr/src/homeassistant/homeassistant/__main__.py", line 209, in main exit_code = runner.run(runtime_conf) File "/usr/src/homeassistant/homeassistant/runner.py", line 189, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.12/asyncio/base_events.py", line 674, in run_until_complete self.run_forever() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 641, in run_forever self._run_once() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1990, in _run_once handle._run() File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run self._context.run(self._callback, *self._args) File "/usr/src/homeassistant/homeassistant/setup.py", line 165, in async_setup_component result = await _async_setup_component(hass, domain, config) File "/usr/src/homeassistant/homeassistant/setup.py", line 334, in _async_setup_component component = await integration.async_get_component() File "/usr/src/homeassistant/homeassistant/loader.py", line 1023, in async_get_component comp = self._get_component() File "/usr/src/homeassistant/homeassistant/loader.py", line 1071, in _get_component ComponentProtocol, importlib.import_module(self.pkg_path)
Detected blocking call to import_module with args ('custom_components.bermuda.config_flow',) in /usr/src/homeassistant/homeassistant/loader.py, line 1300: return importlib.import_module(f"{self.pkg_path}.{platform_name}") 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 223, in <module> sys.exit(main()) File "/usr/src/homeassistant/homeassistant/__main__.py", line 209, in main exit_code = runner.run(runtime_conf) File "/usr/src/homeassistant/homeassistant/runner.py", line 189, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.12/asyncio/base_events.py", line 674, in run_until_complete self.run_forever() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 641, in run_forever self._run_once() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1990, in _run_once handle._run() File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run self._context.run(self._callback, *self._args) File "/usr/src/homeassistant/homeassistant/util/async_.py", line 112, in sem_task return await task File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1295, in async_init flow, result = await self._async_init(flow_id, handler, context, data) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1320, in _async_init flow = await self.async_create_flow(handler, context=context, data=data) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1511, in async_create_flow handler = await _async_get_flow_handler( File "/usr/src/homeassistant/homeassistant/config_entries.py", line 3238, in _async_get_flow_handler await _load_integration(hass, domain, hass_config) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 3217, in _load_integration await integration.async_get_platform("config_flow") File "/usr/src/homeassistant/homeassistant/loader.py", line 1104, in async_get_platform platforms = await self.async_get_platforms((platform_name,)) File "/usr/src/homeassistant/homeassistant/loader.py", line 1169, in async_get_platforms platforms.update(self._load_platforms(platform_names)) File "/usr/src/homeassistant/homeassistant/loader.py", line 1094, in _load_platforms platform_name: self._load_platform(platform_name) File "/usr/src/homeassistant/homeassistant/loader.py", line 1268, in _load_platform cache[full_name] = self._import_platform(platform_name) File "/usr/src/homeassistant/homeassistant/loader.py", line 1300, in _import_platform return importlib.import_module(f"{self.pkg_path}.{platform_name}")
Logger: homeassistant.config_entries
Source: config_entries.py:3219
First occurred: 03:09:40 (83 occurrences)
Last logged: 06:54:50
Error occurred loading flow for integration bermuda: cannot import name 'Config' from 'homeassistant.core' (/usr/src/homeassistant/homeassistant/core.py)
Please note this third one happened 4h after the other two. All those messages came up with Home Assistant starting up.
The update to v2024.11.0b0 happened right before the first messages and Bermuda isn't working since then.
Diagnostics
Not available as the integration isn't being loaded.
** Additional resources
- HA Beta channel on Discord where other people is talking about this issue: https://discord.com/channels/330944238910963714/427516175237382144/1301258483118903369
- Proposed fix for similar issue with Nordpool integration: https://github.com/custom-components/nordpool/pull/433/files
Fantastic report, thank you! I rarely get a chance to spin up the betas so I really appreciate the heads-up!
I'll dig into this asap.
This may give you time to fix the issue: home-assistant/core#129537
I let you know as soon b1 is out.
Seems like this code was already removed in #262 but not released as stable yet.
@edwardtfn try out v0.6.9rc1 or v0.6.9rc2.
Just worked that out myself! :-) Defs try rc2.
The first and last issues seem specific to versions before 0.6.8 and were fixed by 0.6.9rc2.
The second issue appears to be a fault in HA, not Bermuda?
Version | Results |
---|---|
v0.6.8 | Failed |
v0.6.9rc1 | Loaded fine, everything looks to be working properly |
v0.6.9rc2 | Loaded fine, everything looks to be working properly |
The beta did raise an error about calling async_config_entry_first_refresh()
when not in the right state, so I was able to fix that, though - and I'll do some ongoing testing.
Config needs to be imported from core_config instead of core, but it's no longer breaking in the latest betas. Will break somewhere in 2025.
Yeah Bermuda was already fixed in 0.6.9rc2, so will be in the next release 👍🏼
Actually I'll close this now on that basis, but please raise new tickets if anything else comes up from the betas!