Fix Opower accounts that report cost less regularly than usage (#114034)

* Update coordinator.py

* Update coordinator.py
pull/89350/head^2
tronikos 2024-03-26 14:20:16 -07:00 committed by GitHub
parent 72fed878b4
commit a6fabdc115
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -109,7 +109,7 @@ class OpowerCoordinator(DataUpdateCoordinator[dict[str, Forecast]]):
)
last_stat = await get_instance(self.hass).async_add_executor_job(
get_last_statistics, self.hass, 1, consumption_statistic_id, True, set()
get_last_statistics, self.hass, 1, cost_statistic_id, True, set()
)
if not last_stat:
_LOGGER.debug("Updating statistic for the first time")
@ -119,7 +119,7 @@ class OpowerCoordinator(DataUpdateCoordinator[dict[str, Forecast]]):
last_stats_time = None
else:
cost_reads = await self._async_get_recent_cost_reads(
account, last_stat[consumption_statistic_id][0]["start"]
account, last_stat[cost_statistic_id][0]["start"]
)
if not cost_reads:
_LOGGER.debug("No recent usage/cost data. Skipping update")