ldotlopez / ha-ideenergy

ideenergy integration for home-assistant
GNU General Public License v3.0
73 stars 13 forks source link

Setup failed for custom integration ideenergy: Unable to import component: Exception importing custom_components.ideenergy #32

Closed milkywade closed 1 year ago

milkywade commented 1 year ago

Using Home Assistant Core 2023.1.3, HACS v1.29.1, I-DE Energy Monitor v1.0.1 on a Raspberry pi 3B+ with bullseye 64b and python 3.9.2

HASS loads, HACS loads but the ideenergy sensor fails setup.

Full text for exception raised in HASS log is:

Jan 11 23:59:34 TEST01 hass[104948]: 2023-01-11 23:59:34.626 ERROR (MainThread) [homeassistant.loader] Unexpected exception importing component custom_components.ideenergy
Jan 11 23:59:34 TEST01 hass[104948]: Traceback (most recent call last):
Jan 11 23:59:34 TEST01 hass[104948]:   File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/loader.py", line 725, in get_component
Jan 11 23:59:34 TEST01 hass[104948]:     cache[self.domain] = importlib.import_module(self.pkg_path)
Jan 11 23:59:34 TEST01 hass[104948]:   File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
Jan 11 23:59:34 TEST01 hass[104948]:     return _bootstrap._gcd_import(name[level:], package, level)
Jan 11 23:59:34 TEST01 hass[104948]:   File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
Jan 11 23:59:34 TEST01 hass[104948]:   File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
Jan 11 23:59:34 TEST01 hass[104948]:   File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
Jan 11 23:59:34 TEST01 hass[104948]:   File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
Jan 11 23:59:34 TEST01 hass[104948]:   File "<frozen importlib._bootstrap_external>", line 790, in exec_module
Jan 11 23:59:34 TEST01 hass[104948]:   File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
Jan 11 23:59:34 TEST01 hass[104948]:   File "/home/homeassistant/.homeassistant/custom_components/ideenergy/__init__.py", line 34, in <module>
Jan 11 23:59:34 TEST01 hass[104948]:     from .barrier import TimeDeltaBarrier, TimeWindowBarrier  # NoopBarrier,
Jan 11 23:59:34 TEST01 hass[104948]:   File "/home/homeassistant/.homeassistant/custom_components/ideenergy/barrier.py", line 49, in <module>
Jan 11 23:59:34 TEST01 hass[104948]:     param: str | int, default_tzinfo=datetime.timezone.utc, optional=False
Jan 11 23:59:34 TEST01 hass[104948]: TypeError: unsupported operand type(s) for |: 'type' and 'type'
Jan 11 23:59:34 TEST01 hass[104948]: 2023-01-11 23:59:34.632 ERROR (MainThread) [homeassistant.setup] Setup failed for custom integration ideenergy: Unable to import component: Exception importing custom_components.ideenergy
ldotlopez commented 1 year ago

Hi @milkywade,

It's a compatibility issue with python3.9, my fault.

I made some changes (https://github.com/ldotlopez/ha-ideenergy/commit/5eb85baa9c4c5daf667cde2e1d808a542b710f4c) in main git branch, can you test it? I don't have access to any python3.9 installation.

milkywade commented 1 year ago

Hi @ldotlopez - I just deployed and restarted. No errors now. Many thanks !

ldotlopez commented 1 year ago

I just released v1.0.2 with this change.

Please, revert your version from main to 1.0.2 to avoid possible breakages.

milkywade commented 1 year ago

Hi @idotlopez good day. Because of the above, the first day it worked again I noticed I have a _negative 265 kWh reading in my energy monitor that is polluting a bit the stats.

Is there a quick way to fix it ? Else it's no big deal. Thank you.

image