Reduce size of get_statistics_during_period WS API response (#82131)

This commit is contained in:
Erik Montnemery 2022-11-16 17:36:30 +01:00 committed by GitHub
parent bb64b39d0e
commit 607a0e7697
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 588 additions and 591 deletions

View file

@ -591,7 +591,7 @@ class TibberDataCoordinator(DataUpdateCoordinator):
)
last_stats = await get_instance(self.hass).async_add_executor_job(
get_last_statistics, self.hass, 1, statistic_id, True
get_last_statistics, self.hass, 1, statistic_id, True, {}
)
if not last_stats:
@ -613,7 +613,7 @@ class TibberDataCoordinator(DataUpdateCoordinator):
else home.hourly_consumption_data
)
from_time = dt_util.parse_datetime(hourly_data[0]["from"])
from_time = hourly_data[0]["from"]
if from_time is None:
continue
start = from_time - timedelta(hours=1)
@ -624,7 +624,8 @@ class TibberDataCoordinator(DataUpdateCoordinator):
None,
[statistic_id],
"hour",
True,
None,
{"sum"},
)
_sum = stat[statistic_id][0]["sum"]
last_stats_time = stat[statistic_id][0]["start"]