nordicopen / easee_hass

Custom component for Easee EV charger integration with Home Assistant
216 stars 37 forks source link

Another error after upgrading from 0.9.61 to 0.9.62 (a different one) #490

Closed wywywywy closed 1 month ago

wywywywy commented 1 month ago

Before creating an issue...

The problem

Another failure after upgrading to the latest version. But this time the error is different, and also I think it did manage to install the dependency?

Main part is here:

easee/const.py line 151

AttributeError: type object 'EqualizerStreamData' has no attribute 'config_surplusCharging'. Did you mean: 'state_surplusCharging'?

Any ideas please?

Version of Easee integration having the issue?

0.9.62

Version of Home Assistant Core having the issue?

2024.10.2

Anything in the logs that might be useful for us?

Traceback (most recent call last):
  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/easee/__init__.py", line 11, in <module>
    from .const import DOMAIN, LISTENER_FN_CLOSE, MIN_HA_VERSION, PLATFORMS, VERSION
  File "/config/custom_components/easee/const.py", line 151, in <module>
    EqualizerStreamData.config_surplusCharging.value,
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'EqualizerStreamData' has no attribute 'config_surplusCharging'. Did you mean: 'state_surplusCharging'?

The above exception was the direct cause of the following exception:

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 1078, in _get_component
    raise ImportError(f"Exception importing {self.pkg_path}") from err
ImportError: Exception importing custom_components.easee

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  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/easee/__init__.py", line 11, in <module>
    from .const import DOMAIN, LISTENER_FN_CLOSE, MIN_HA_VERSION, PLATFORMS, VERSION
  File "/config/custom_components/easee/const.py", line 151, in <module>
    EqualizerStreamData.config_surplusCharging.value,
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'EqualizerStreamData' has no attribute 'config_surplusCharging'. Did you mean: 'state_surplusCharging'?

The above exception was the direct cause of the following exception:

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 1078, in _get_component
    raise ImportError(f"Exception importing {self.pkg_path}") from err
ImportError: Exception importing custom_components.easee

Additional information

I'm using the Home Assistant stable container.

The pyeasee v0.8.5 seems to have installed already, so I'm guessing it's not a dependency problem, but I could be wrong.

homeassistant-0:/# ls /config/deps
aiohappyeyeballs                  msgpack-1.1.0.dist-info
aiohappyeyeballs-2.4.3.dist-info  msgpack.libs
aiohttp                           multidict
aiohttp-3.10.8.dist-info          multidict-6.1.0.dist-info
aiohttp.libs                      multidict.libs
aiosignal                         orjson
aiosignal-1.3.1.dist-info         orjson-3.10.7.dist-info
attr                              pyeasee
attrs                             pyeasee-0.8.5.dist-info
attrs-23.2.0.dist-info            pysignalr
bin                               pysignalr-1.0.0.dist-info
frozenlist                        websockets
frozenlist-1.4.1.dist-info        websockets-12.0.dist-info
frozenlist.libs                   websockets.libs
idna                              yarl
idna-3.10.dist-info               yarl-1.13.1.dist-info
lib                               yarl.libs
olalid commented 1 month ago

Most likely the libs you are listing are not the python libs in the HA environment. The version of pyeasee that HA loads is not the correct version, this is a change that was made in both lib and component in the recent versions, so something is stopping HA from installing the correct version. If you search for pyeasee in home-assistant.log, can you not see what version is loaded there? Did you turn on debug logging as described in the readme?

wywywywy commented 1 month ago

Thanks for the prompt reply.

When searching for pyeasee, it shows this, nothing else.

2024-10-18 14:38:17.693 INFO (SyncWorker_0) [homeassistant.util.package] Attempting install of pyeasee==0.8.5

Are you saying there's another place HA loads python libs? I only know of /config/deps and of course /usr/local/lib/python3.12/site-packages. And pyeasee-0.8.5 is in /config/deps.

olalid commented 1 month ago

If you see the line "Attempting install of pyeasee==0.8.5" every time you start HA it means it is trying to install pyeasee 0.8.5 but fails for some reason. I would expect some kind of error message a few lines further down.

I can not tell by the information you have provided if the location you are pointing to are the location where HA loads libs from. It is common that HA runs in some kind of virtual environment that is different from the user environment. What kind of installation do you have?

olalid commented 1 month ago

A normal startup would have these 2 lines in the log file (if you have first enabled debug logging as described in the readme). 2024-10-19 16:13:55.279 DEBUG (MainThread) [custom_components.easee] Setting up Easee component version 0.9.62 2024-10-19 16:13:55.279 INFO (MainThread) [pyeasee.easee] Easee python library version: 0.8.5

wywywywy commented 1 month ago

Hi. So it turns out there are indeed multiple places to store Python packages.

  1. /config/deps/
  2. /config/deps/lib/python3.12/site-packages/
  3. /usr/local/lib/python3.12/site-packages/

HA wants to install pyeasee to /config/deps/, but then it tries to import packages from /config/deps/lib/python3.12/site-packages/ for some reasons.

So anyway, I fixed it with PYTHONPATH=/config/deps/lib/python3.12/site-packages pip install --upgrade pyeasee==0.8.5 inside of the container, and it's working fine now.

Thanks for your help.