2022-10-18 21:53:30.886 ERROR (MainThread) [homeassistant.loader] Unexpected exception importing component custom_components.powercalc
Traceback (most recent call last):
File "/srv/homeassistant/pyvenv/lib/python3.9/site-packages/homeassistant/loader.py", line 703, in get_component
cache[self.domain] = importlib.import_module(self.pkg_path)
File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 790, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/srv/homeassistant/.homeassistant/custom_components/powercalc/__init__.py", line 90, in <module>
from .sensors.group import update_associated_group_entry
File "/srv/homeassistant/.homeassistant/custom_components/powercalc/sensors/group.py", line 58, in <module>
from .energy import EnergySensor, RealEnergySensor
File "/srv/homeassistant/.homeassistant/custom_components/powercalc/sensors/energy.py", line 33, in <module>
from .power import PowerSensor, RealPowerSensor
File "/srv/homeassistant/.homeassistant/custom_components/powercalc/sensors/power.py", line 69, in <module>
from ..strategy.factory import PowerCalculatorStrategyFactory
File "/srv/homeassistant/.homeassistant/custom_components/powercalc/strategy/factory.py", line 18, in <module>
from .fixed import FixedStrategy
File "/srv/homeassistant/.homeassistant/custom_components/powercalc/strategy/fixed.py", line 17, in <module>
from .strategy_interface import PowerCalculationStrategyInterface
File "/srv/homeassistant/.homeassistant/custom_components/powercalc/strategy/strategy_interface.py", line 7, in <module>
class PowerCalculationStrategyInterface:
File "/srv/homeassistant/.homeassistant/custom_components/powercalc/strategy/strategy_interface.py", line 8, in PowerCalculationStrategyInterface
async def calculate(self, entity_state: State) -> Decimal | None:
TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'
Hi Bram
When trying to test your integration i get the following exception. I'm running this on debian bullseye (python 3.9)
From looking at the code and github i identified #1147 I'm unsure but it seems to me that you are introducing a hard dependency on python 3.10.
From: https://docs.python.org/3/library/typing.html Changed in version 3.10: Optional can now be written as X | None.
Is this intented?
Thanks