mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Request one data point in statistics_during_period in Opower (#124480)
This commit is contained in:
parent
cbd884d54a
commit
17994ff245
@ -128,19 +128,22 @@ class OpowerCoordinator(DataUpdateCoordinator[dict[str, Forecast]]):
|
|||||||
if not cost_reads:
|
if not cost_reads:
|
||||||
_LOGGER.debug("No recent usage/cost data. Skipping update")
|
_LOGGER.debug("No recent usage/cost data. Skipping update")
|
||||||
continue
|
continue
|
||||||
|
start = cost_reads[0].start_time
|
||||||
|
_LOGGER.debug("Getting statistics at: %s", start)
|
||||||
stats = await get_instance(self.hass).async_add_executor_job(
|
stats = await get_instance(self.hass).async_add_executor_job(
|
||||||
statistics_during_period,
|
statistics_during_period,
|
||||||
self.hass,
|
self.hass,
|
||||||
cost_reads[0].start_time,
|
start,
|
||||||
None,
|
start + timedelta(seconds=1),
|
||||||
{cost_statistic_id, consumption_statistic_id},
|
{cost_statistic_id, consumption_statistic_id},
|
||||||
"hour" if account.meter_type == MeterType.ELEC else "day",
|
"hour",
|
||||||
None,
|
None,
|
||||||
{"sum"},
|
{"sum"},
|
||||||
)
|
)
|
||||||
cost_sum = cast(float, stats[cost_statistic_id][0]["sum"])
|
cost_sum = cast(float, stats[cost_statistic_id][0]["sum"])
|
||||||
consumption_sum = cast(float, stats[consumption_statistic_id][0]["sum"])
|
consumption_sum = cast(float, stats[consumption_statistic_id][0]["sum"])
|
||||||
last_stats_time = stats[consumption_statistic_id][0]["start"]
|
last_stats_time = stats[consumption_statistic_id][0]["start"]
|
||||||
|
assert last_stats_time == start.timestamp()
|
||||||
|
|
||||||
cost_statistics = []
|
cost_statistics = []
|
||||||
consumption_statistics = []
|
consumption_statistics = []
|
||||||
|
Loading…
x
Reference in New Issue
Block a user