CharlesGillanders / homeassistant-alphaESS

Monitor your energy generation, storage, and usage data using the official API from Alpha ESS.
MIT License
101 stars 22 forks source link

Error while Inverter is offline #58

Closed ckarrie closed 1 year ago

ckarrie commented 1 year ago

Hi, I get following error after initialization of the integration while my Inverter is offline:

Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/homeassistant/helpers/update_coordinator.py", line 225, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/alphaess/coordinator.py", line 46, in _async_update_data
    inverterdata.update({"Instantaneous Grid I/O L1": invertor["powerdata"]["pmeter_l1"]})
TypeError: 'NoneType' object is not subscriptable

One solution could be to make the dict more robuts, i.e.

invertor.get("powerdata", {}).get("pmeter_l1", None)

instead of

invertor["powerdata"]["pmeter_l1"]

ckarrie commented 1 year ago

see https://github.com/CharlesGillanders/homeassistant-alphaESS/pull/60 for a fix proposal

CharlesGillanders commented 1 year ago

I have merged your pull request and pushed a new release that includes your fix. Thank you!