dlarrick / hass-kumo

Home Assistant module interfacing with Mitsubishi mini-split units
MIT License
97 stars 21 forks source link

Error after updating to HA Core Version: 2024.8.0 #161

Closed SR-Coder closed 1 month ago

SR-Coder commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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

omriasta commented 1 month ago

@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 commented 1 month ago

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

SR-Coder commented 1 month ago

@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 commented 1 month ago

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

dlarrick commented 1 month ago

I will just make the next version depend on whenever they put that function in its new location. -Doug

On Wed, Aug 7, 2024, 5:52 PM omriasta @.***> wrote:

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

— Reply to this email directly, view it on GitHub https://github.com/dlarrick/hass-kumo/issues/161#issuecomment-2274412140, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUE6FOJAWUVGJOQRMASX23ZQKJJXAVCNFSM6AAAAABMFGZKWKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZUGQYTEMJUGA . You are receiving this because you were mentioned.Message ID: @.***>

dlarrick commented 1 month ago

Breadcrumb: https://github.com/home-assistant/core/pull/88099 introduced save_json to helpers

edjurkowski commented 1 month ago

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

dlarrick commented 1 month ago

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.