gtdiehl / iotawatt_ha

IoTaWatt for Home Assistant
Apache License 2.0
16 stars 16 forks source link

Entering wrong credentials does not stop setup #21

Open gtdiehl opened 3 years ago

gtdiehl commented 3 years ago

During setup of the IoTaWatt if the user enters the wrong credentials the setup continues and the log is flooded with these exceptions:

2021-08-27 21:09:37 ERROR (MainThread) [homeassistant.components.iotawatt] Unexpected error fetching IoTaWatt data: Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
  File "/workspaces/core/homeassistant/helpers/update_coordinator.py", line 187, in _async_refresh
    self.data = await self._async_update_data()
  File "/workspaces/core/homeassistant/components/iotawatt/__init__.py", line 106, in _async_update_data
    await self.api.update()
  File "/usr/local/lib/python3.9/site-packages/iotawattpy/iotawatt.py", line 66, in update
    await self._refreshSensors(timespan)
  File "/usr/local/lib/python3.9/site-packages/iotawattpy/iotawatt.py", line 101, in _refreshSensors
    results = json.loads(results)
  File "/usr/local/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.9/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

In the Configuration >> Integrations page the tile will be red indicating a problem. User can delete and re-add using the correct credentials.

Screen Shot 2021-08-27 at 2 16 29 PM