mirror of
https://github.com/home-assistant/core.git
synced 2025-08-04 11:08:17 +00:00
Make history coordinator more reliable in Tesla Fleet (#149854)
This commit is contained in:
parent
3e615fd373
commit
7dd2b9e422
@ -247,11 +247,15 @@ class TeslaFleetEnergySiteHistoryCoordinator(DataUpdateCoordinator[dict[str, Any
|
|||||||
raise UpdateFailed(e.message) from e
|
raise UpdateFailed(e.message) from e
|
||||||
self.updated_once = True
|
self.updated_once = True
|
||||||
|
|
||||||
|
if not data or not isinstance(data.get("time_series"), list):
|
||||||
|
raise UpdateFailed("Received invalid data")
|
||||||
|
|
||||||
# Add all time periods together
|
# Add all time periods together
|
||||||
output = dict.fromkeys(ENERGY_HISTORY_FIELDS, 0)
|
output = dict.fromkeys(ENERGY_HISTORY_FIELDS, 0)
|
||||||
for period in data.get("time_series", []):
|
for period in data.get("time_series", []):
|
||||||
for key in ENERGY_HISTORY_FIELDS:
|
for key in ENERGY_HISTORY_FIELDS:
|
||||||
output[key] += period.get(key, 0)
|
if key in period:
|
||||||
|
output[key] += period[key]
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user