Skip to content

Commit

Permalink
Be a bit more defensive on empty data
Browse files Browse the repository at this point in the history
Signed-off-by: Olivier Mehani <[email protected]>
  • Loading branch information
shtrom committed Aug 9, 2023
1 parent 20bc429 commit c715e32
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions custom_components/auroraplus/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,12 @@ async def async_update(self):
float(self._api.EstimatedBalance), self._rounding)
elif self._sensor == SENSOR_DOLLARVALUEUSAGE:
self._state = round(
self._api.DollarValueUsage['Total'], self._rounding)
self._api.DollarValueUsage.get('Total', float('nan')),
self._rounding)
elif self._sensor == SENSOR_KILOWATTHOURUSAGE:
self._state = round(
self._api.KilowattHourUsage['Total'], self._rounding)
self._api.KilowattHourUsage.get('Total', float('nan')),
self._rounding)
elif self._sensor.startswith(SENSOR_KILOWATTHOURUSAGETARIFF):
pass

Expand Down

0 comments on commit c715e32

Please sign in to comment.