mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 07:07:28 +00:00
Add debug logging in get_cost_reads in opower (#124473)
Add debug statements in get_cost_reads in opower
This commit is contained in:
parent
c4c8e74a8a
commit
c2b24dd355
@ -236,9 +236,11 @@ class OpowerCoordinator(DataUpdateCoordinator[dict[str, Forecast]]):
|
|||||||
else:
|
else:
|
||||||
start = datetime.fromtimestamp(start_time, tz=tz) - timedelta(days=30)
|
start = datetime.fromtimestamp(start_time, tz=tz) - timedelta(days=30)
|
||||||
end = dt_util.now(tz)
|
end = dt_util.now(tz)
|
||||||
|
_LOGGER.debug("Getting monthly cost reads: %s - %s", start, end)
|
||||||
cost_reads = await self.api.async_get_cost_reads(
|
cost_reads = await self.api.async_get_cost_reads(
|
||||||
account, AggregateType.BILL, start, end
|
account, AggregateType.BILL, start, end
|
||||||
)
|
)
|
||||||
|
_LOGGER.debug("Got %s monthly cost reads", len(cost_reads))
|
||||||
if account.read_resolution == ReadResolution.BILLING:
|
if account.read_resolution == ReadResolution.BILLING:
|
||||||
return cost_reads
|
return cost_reads
|
||||||
|
|
||||||
@ -249,9 +251,11 @@ class OpowerCoordinator(DataUpdateCoordinator[dict[str, Forecast]]):
|
|||||||
start = cost_reads[0].start_time
|
start = cost_reads[0].start_time
|
||||||
assert start
|
assert start
|
||||||
start = max(start, end - timedelta(days=3 * 365))
|
start = max(start, end - timedelta(days=3 * 365))
|
||||||
|
_LOGGER.debug("Getting daily cost reads: %s - %s", start, end)
|
||||||
daily_cost_reads = await self.api.async_get_cost_reads(
|
daily_cost_reads = await self.api.async_get_cost_reads(
|
||||||
account, AggregateType.DAY, start, end
|
account, AggregateType.DAY, start, end
|
||||||
)
|
)
|
||||||
|
_LOGGER.debug("Got %s daily cost reads", len(daily_cost_reads))
|
||||||
_update_with_finer_cost_reads(cost_reads, daily_cost_reads)
|
_update_with_finer_cost_reads(cost_reads, daily_cost_reads)
|
||||||
if account.read_resolution == ReadResolution.DAY:
|
if account.read_resolution == ReadResolution.DAY:
|
||||||
return cost_reads
|
return cost_reads
|
||||||
@ -261,8 +265,11 @@ class OpowerCoordinator(DataUpdateCoordinator[dict[str, Forecast]]):
|
|||||||
else:
|
else:
|
||||||
assert start
|
assert start
|
||||||
start = max(start, end - timedelta(days=2 * 30))
|
start = max(start, end - timedelta(days=2 * 30))
|
||||||
|
_LOGGER.debug("Getting hourly cost reads: %s - %s", start, end)
|
||||||
hourly_cost_reads = await self.api.async_get_cost_reads(
|
hourly_cost_reads = await self.api.async_get_cost_reads(
|
||||||
account, AggregateType.HOUR, start, end
|
account, AggregateType.HOUR, start, end
|
||||||
)
|
)
|
||||||
|
_LOGGER.debug("Got %s hourly cost reads", len(hourly_cost_reads))
|
||||||
_update_with_finer_cost_reads(cost_reads, hourly_cost_reads)
|
_update_with_finer_cost_reads(cost_reads, hourly_cost_reads)
|
||||||
|
_LOGGER.debug("Got %s cost reads", len(cost_reads))
|
||||||
return cost_reads
|
return cost_reads
|
||||||
|
Loading…
x
Reference in New Issue
Block a user