Reduce size of get_statistics_during_period WS API response (#82131)
This commit is contained in:
parent
bb64b39d0e
commit
607a0e7697
12 changed files with 588 additions and 591 deletions
|
@ -450,7 +450,7 @@ def _compile_statistics( # noqa: C901
|
|||
to_query.append(entity_id)
|
||||
|
||||
last_stats = statistics.get_latest_short_term_statistics(
|
||||
hass, to_query, metadata=old_metadatas
|
||||
hass, to_query, {"last_reset", "state", "sum"}, metadata=old_metadatas
|
||||
)
|
||||
for ( # pylint: disable=too-many-nested-blocks
|
||||
entity_id,
|
||||
|
@ -508,6 +508,8 @@ def _compile_statistics( # noqa: C901
|
|||
if entity_id in last_stats:
|
||||
# We have compiled history for this sensor before, use that as a starting point
|
||||
last_reset = old_last_reset = last_stats[entity_id][0]["last_reset"]
|
||||
if old_last_reset is not None:
|
||||
last_reset = old_last_reset = old_last_reset.isoformat()
|
||||
new_state = old_state = last_stats[entity_id][0]["state"]
|
||||
_sum = last_stats[entity_id][0]["sum"] or 0.0
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue