Skip to content

Commit

Permalink
Request one data point in statistics_during_period in Opower (home-as…
Browse files Browse the repository at this point in the history
  • Loading branch information
tronikos authored Sep 7, 2024
1 parent cbd884d commit 17994ff
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions homeassistant/components/opower/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,22 @@ async def _insert_statistics(self) -> None:
if not cost_reads:
_LOGGER.debug("No recent usage/cost data. Skipping update")
continue
start = cost_reads[0].start_time
_LOGGER.debug("Getting statistics at: %s", start)
stats = await get_instance(self.hass).async_add_executor_job(
statistics_during_period,
self.hass,
cost_reads[0].start_time,
None,
start,
start + timedelta(seconds=1),
{cost_statistic_id, consumption_statistic_id},
"hour" if account.meter_type == MeterType.ELEC else "day",
"hour",
None,
{"sum"},
)
cost_sum = cast(float, stats[cost_statistic_id][0]["sum"])
consumption_sum = cast(float, stats[consumption_statistic_id][0]["sum"])
last_stats_time = stats[consumption_statistic_id][0]["start"]
assert last_stats_time == start.timestamp()

cost_statistics = []
consumption_statistics = []
Expand Down

0 comments on commit 17994ff

Please sign in to comment.