bouwew / sems2mqtt

GoodWe SEMS MQTT-componenent for Home Assistant
MIT License
10 stars 9 forks source link

API data fetch error #13

Closed jonisnet closed 2 years ago

jonisnet commented 2 years ago

Like i all ready told in discussion i Hass core regularly reboots because there is a problem with the API in sems2mqtt. Below is a log of Hass core.

`Message: 'Unable to fetch data from the SEMS API,'
Arguments: (KeyError('inverter'), 'not available')
2021-11-01 10:11:25 WARNING (MainThread) [custom_components.sems2mqtt] HTTPSConnectionPool(host='eu.semsportal.com', port=443): Read timed out. (read timeout=20)

--- Logging error ---
2021-11-01 10:12:32 ERROR (MainThread) [custom_components.sems2mqtt] Failed to obtain data from the SEMS API
Traceback (most recent call last):
File "/config/custom_components/sems2mqtt/__init__.py", line 207, in async_get_sems_data
    data = await getCurrentReadings(station)
File "/config/custom_components/sems2mqtt/__init__.py", line 117, in getCurrentReadings
    inverterData = data['inverter'][0]['invert_full']
KeyError: 'inverter'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/logging/handlers.py", line 1432, in emit
    self.enqueue(self.prepare(record))
  File "/usr/local/lib/python3.9/logging/handlers.py", line 1415, in prepare
    msg = self.format(record)
  File "/usr/local/lib/python3.9/logging/__init__.py", line 927, in format
    return fmt.format(record)
  File "/usr/local/lib/python3.9/logging/__init__.py", line 663, in format
    record.message = record.getMessage()
  File "/usr/local/lib/python3.9/logging/__init__.py", line 367, in getMessage
    msg = msg % self.args`

Hopefully you can help to fix this problem and if you need more information just ask me.

Gr Kees

bouwew commented 2 years ago

@jonisnet can you please test v0.4.4-beta.0? Should become visible when enabling "Show beta" in HACS.

jonisnet commented 2 years ago

@bouwew 2 days ago i installed the beta and it seems to work without significant errors. There are still some API errors but it looks like thats more on the goodwe side because the normal login on there website and andriod app (with an other account on the same invertor) is really buggy aswell.

So my conclussion is that your fix works because there has been no unwanted hass core restarts after the update.

Gr Kees

bouwew commented 2 years ago

Thanks for testing! v0.4.4 is now available for everyone.