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

Error after updating to HA Core Version: 2024.8.0 #161

Closed
SR-Coder opened this issue Aug 7, 2024 · 10 comments
Closed

Error after updating to HA Core Version: 2024.8.0 #161

SR-Coder opened this issue Aug 7, 2024 · 10 comments

Comments

@SR-Coder
Copy link

SR-Coder commented Aug 7, 2024

Kumo integration fails to load.

Source: setup.py:334
First occurred: 1:42:45 PM (1 occurrences)
Last logged: 1:42:45 PM

Setup failed for custom integration 'kumo': Unable to import component: cannot import name 'save_json' from 'homeassistant.util.json' (/usr/src/homeassistant/homeassistant/util/json.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/kumo/__init__.py", line 11, in <module>
    from homeassistant.util.json import load_json, save_json
ImportError: cannot import name 'save_json' from 'homeassistant.util.json' (/usr/src/homeassistant/homeassistant/util/json.py)

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 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/kumo/__init__.py", line 11, in <module>
    from homeassistant.util.json import load_json, save_json
ImportError: cannot import name 'save_json' from 'homeassistant.util.json' (/usr/src/homeassistant/homeassistant/util/json.py)
@omriasta
Copy link
Collaborator

omriasta commented Aug 7, 2024

Just ran into this as well.
@dlarrick I don't have a laptop right now to create a PR but we just need to change the location we import save_json from. It is now in homeassistant.helpers.json
@SR-Coder if you are comfortable manually editing the file, you just need to change the lines in init.py and config_flow.py
Remove save_json from where it currently is (and the comma right before, then add a new line:
from homeassistant.helpers.json import save_json

@SR-Coder
Copy link
Author

SR-Coder commented Aug 7, 2024

@omriasta not a problem I will make those changes and report back! Thanks for the quick response!

@omriasta
Copy link
Collaborator

omriasta commented Aug 7, 2024

@dlarrick I was able to create a PR on my phone because it was just 2 lines of code.
I am not sure if this will break previous versions of HA though.

@omriasta
Copy link
Collaborator

omriasta commented Aug 7, 2024

@SR-Coder you can see what needs to be updated here:
https://github.com/dlarrick/hass-kumo/pull/162/files

@SR-Coder
Copy link
Author

SR-Coder commented Aug 7, 2024

@omriasta Thanks for the super quick response, HA is running a database update so when that is done I will restart and that should reload Kumo Integration. Perhaps until a final solution is made wrap the import in a try and except to handle the previous versions importing from a different location. cheers

@omriasta
Copy link
Collaborator

omriasta commented Aug 7, 2024

Yep, that may be the way to go...just hard to write up from my phone.

@dlarrick
Copy link
Owner

dlarrick commented Aug 7, 2024 via email

@dlarrick
Copy link
Owner

dlarrick commented Aug 8, 2024

Breadcrumb: home-assistant/core#88099 introduced save_json to helpers

@edjurkowski
Copy link

I made the edit to files as @SR-Coder directed. Kumo is working. Thanks

@dlarrick
Copy link
Owner

dlarrick commented Aug 9, 2024

Fixed in v0.3.14 . I bumped the HACS dependency on HomeAssistant version to be one with the required save_json function. The manifest dependency was already fine.

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

4 participants