kirei / hass-chargeamps

Home Assistant Component for Chargeamps
Other
26 stars 8 forks source link

Integration Won't Load Since HA 2023.11 #42

Closed rwdnnz closed 3 months ago

rwdnnz commented 1 year ago

Since upgrading to HA 2023.11 this component won't load and shows the following errors in the logs:

2023-11-03 20:04:06.155 ERROR (MainThread) [homeassistant.loader] Unexpected exception importing component custom_components.chargeamps File "/config/custom_components/chargeamps/__init__.py", line 14, in <module> from chargeamps.base import ( File "/usr/local/lib/python3.11/site-packages/chargeamps/__init__.py", line 3, in <module> __version__ = pkg_resources.get_distribution("chargeamps").version pkg_resources.ContextualVersionConflict: (dataclasses-json 0.6.1 (/usr/local/lib/python3.11/site-packages), Requirement.parse('dataclasses-json<0.6.0,>=0.5.2'), {'chargeamps'})

HA is running as a Supervisord install.

Rittsel commented 1 year ago

As a test I changed the version requirement in /config/custom_components/chargeamps/manifest.json

"dataclasses-json>=0.5.14", to "dataclasses-json>=0.6.1",

and then restarted the container, this seem to work as a workaround. I'm also running Supervisord install

Beastlander commented 1 year ago

Also stopped working for me. Couldn't restart Home Assistant at all as it couldn't load the custom component.

I had to comment out the chargeamps section in the configuration.yaml file and change the parameters as Rittsel described in the post above, then restart home assistant and now the integration is working again.

jschlyter commented 1 year ago

Did you all run the latest version of the component? I cannot replicated this when up to date.

Rittsel commented 1 year ago

@jschlyter yes - running 1.8.4

Beastlander commented 1 year ago

Did you all run the latest version of the component? I cannot replicated this when up to date.

Yeah, I also run 1.8.4

m4n63 commented 1 year ago

For what its worth, I updated my HA to 2023.11 today and so far I have not seen any issues with this integration.

jschlyter commented 1 year ago

I've released v1.8.5 with a dependency update for dataclasses-json, perhaps this helps.

hazze76 commented 1 year ago

My integration stopped working when the Supervisor got updated. Will try 1.8 5 tomorrow

a94marbo commented 1 year ago

I get this error message in the log: Dont know if it hekps.

Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/commands.py:230
Integration: Home Assistant WebSocket API ([documentation](https://www.home-assistant.io/integrations/websocket_api), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+websocket_api%22))
First occurred: 15:31:37 (1 occurrences)
Last logged: 15:31:37

[139737776805056] The system cannot restart because the configuration is not valid: Component error: chargeamps - Exception importing custom_components.chargeamps
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 230, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 2035, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2072, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 986, in admin_handler
    await result
  File "/usr/src/homeassistant/homeassistant/components/homeassistant/__init__.py", line 191, in async_handle_core_service
    raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: The system cannot restart because the configuration is not valid: Component error: chargeamps - Exception importing custom_components.chargeamps

and this

Logginformation (FEL)
Logger: homeassistant.loader
Source: loader.py:816
First occurred: 14:19:11 (2 occurrences)
Last logged: 15:31:37

Unexpected exception importing component custom_components.chargeamps
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 816, in get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/config/custom_components/chargeamps/__init__.py", line 14, in <module>
    from chargeamps.base import (
  File "/usr/local/lib/python3.11/site-packages/chargeamps/__init__.py", line 3, in <module>
    __version__ = pkg_resources.get_distribution("chargeamps").version
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pkg_resources/__init__.py", line 528, in get_distribution
    dist = get_provider(dist)
           ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pkg_resources/__init__.py", line 400, in get_provider
    return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
                                            ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pkg_resources/__init__.py", line 968, in require
    needed = self.resolve(parse_requirements(requirements))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pkg_resources/__init__.py", line 829, in resolve
    dist = self._resolve_dist(
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pkg_resources/__init__.py", line 875, in _resolve_dist
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (dataclasses-json 0.6.1 (/usr/local/lib/python3.11/site-packages), Requirement.parse('dataclasses-json<0.6.0,>=0.5.2'), {'chargeamps'})
Kwakksi commented 1 year ago

I have 1.8.5 and got this issue when upgrading to 2023.11.2 so I'm afraid the fix there did not help in my case.

jschlyter commented 1 year ago

Do you any of you have any other custom components loaded? Requirement.parse('dataclasses-json<0.6.0,>=0.5.2') indicates there's something else that blocks the requirement.

amandagruneau commented 1 year ago

Checked all other components and no such requirements. I get "Component error: chargeamps - Exception importing custom_components.chargeamps" when I check configuration. Haven't tired to restart after getting that...

mikeSwe77 commented 12 months ago

I'm also on 1.8.6 (Updated via HACS) and HA 2023.11.3. Before the updates the system complained about invalid config in the notifications window. "The following integrations and platforms could not be set up:

chargeamps (Show logs) Please check your config and logs."

When looking at the logs; `Logger: homeassistant.setup Source: setup.py:215 First occurred: 11:23:03 (1 occurrences) Last logged: 11:23:03

Setup failed for custom integration chargeamps: Unable to import component: Exception importing custom_components.chargeamps Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/loader.py", line 816, in get_component ComponentProtocol, importlib.import_module(self.pkg_path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1204, in _gcd_import File "", line 1176, in _find_and_load File "", line 1147, in _find_and_load_unlocked File "", line 690, in _load_unlocked File "", line 940, in exec_module File "", line 241, in _call_with_frames_removed File "/config/custom_components/chargeamps/init.py", line 14, in from chargeamps.base import ( File "/usr/local/lib/python3.11/site-packages/chargeamps/init.py", line 3, in version = pkg_resources.get_distribution("chargeamps").version ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pkg_resources/init.py", line 528, in get_distribution dist = get_provider(dist) ^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pkg_resources/init.py", line 400, in get_provider return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0] ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pkg_resources/init.py", line 968, in require needed = self.resolve(parse_requirements(requirements)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pkg_resources/init.py", line 829, in resolve dist = self._resolve_dist( ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pkg_resources/init.py", line 875, in _resolve_dist raise VersionConflict(dist, req).with_context(dependent_req) pkg_resources.ContextualVersionConflict: (dataclasses-json 0.6.2 (/usr/local/lib/python3.11/site-packages), Requirement.parse('dataclasses-json<0.6.0,>=0.5.2'), {'chargeamps'})

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

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/setup.py", line 215, in _async_setup_component component = integration.get_component() ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/loader.py", line 824, in get_component raise ImportError(f"Exception importing {self.pkg_path}") from err ImportError: Exception importing custom_components.chargeamps `

And `Logger: homeassistant.components.template.template_entity Source: components/template/template_entity.py:194 Integration: Template (documentation, issues) First occurred: 11:24:21 (1 occurrences) Last logged: 11:24:21

TemplateError('ValueError: Template error: int got invalid input 'None' when rendering template '{{ ((state_attr('switch.ostervagen_2107010229a_1', 'max_current') | int) - 10) 41.5 |int }}' but no default was specified') while processing template 'Template<template=({{ ((state_attr('switch.ostervagen_2107010229a_1', 'max_current') | int) - 10) 41.5 |int }}) renders=4>' for attribute '_brightness' in entity 'light.chargeamps_current'`

Now it refuses to restart due to "Component error: chargeamps - Exception importing custom_components.chargeamps"

jschlyter commented 12 months ago

This integration requires dataclasses-json>=0.5.2, so I wonder what introduces the dataclasses-json<0.6.0 limitation. I'm suspecting a conflict with another integration as I do have 2023.11.3 with 1.8.6 running just fine.

mikeSwe77 commented 12 months ago

Can we provide any datapoints so that we can try to isolate which integrations has this requirement? f.ex. those with problems list all integrations they are running and we try to narrow it down that way? I've looked into my integrations manifest files but no one has a similar data class requirement.

mikeSwe77 commented 11 months ago

I removed the Chargeamp config lines from configuration.yaml, rebooted, reintroduced the config, rebooted and no more error messages.