Skip to content

Commit 52f80a8

Browse files
committed
Be a bit more defensive on empty data
Signed-off-by: Olivier Mehani <[email protected]>
1 parent 0512eff commit 52f80a8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

custom_components/auroraplus/sensor.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,12 @@ async def async_update(self):
237237
float(self._api.EstimatedBalance), self._rounding)
238238
elif self._sensor == SENSOR_DOLLARVALUEUSAGE:
239239
self._state = round(
240-
self._api.DollarValueUsage['Total'], self._rounding)
240+
self._api.DollarValueUsage.get('Total', float('nan')),
241+
self._rounding)
241242
elif self._sensor == SENSOR_KILOWATTHOURUSAGE:
242243
self._state = round(
243-
self._api.KilowattHourUsage['Total'], self._rounding)
244+
self._api.KilowattHourUsage.get('Total', float('nan')),
245+
self._rounding)
244246
elif self._sensor.startswith(SENSOR_KILOWATTHOURUSAGETARIFF):
245247
pass
246248

0 commit comments

Comments
 (0)