mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Prevent energy history returning zero in Teslemetry (#146202)
This commit is contained in:
parent
d82be09ed4
commit
d0d1fb2da7
@ -195,9 +195,13 @@ class TeslemetryEnergyHistoryCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
raise UpdateFailed(e.message) from e
|
raise UpdateFailed(e.message) from e
|
||||||
|
|
||||||
# Add all time periods together
|
# Add all time periods together
|
||||||
output = dict.fromkeys(ENERGY_HISTORY_FIELDS, 0)
|
output = dict.fromkeys(ENERGY_HISTORY_FIELDS, None)
|
||||||
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:
|
||||||
|
if output[key] is None:
|
||||||
|
output[key] = period[key]
|
||||||
|
else:
|
||||||
|
output[key] += period[key]
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
Loading…
x
Reference in New Issue
Block a user