Skip to content

Commit

Permalink
Don't fail when using account from forecast that doesn't have read_re…
Browse files Browse the repository at this point in the history
…solution for backwards compatibility
  • Loading branch information
tronikos committed Aug 8, 2023
1 parent 4547b7c commit 71f8015
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/opower/opower.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ class UsageRead:
consumption: float # taken from consumption.value field, in KWH or THERM


# TODO: remove supports_mfa and accepts_mfa from all files after ConEd is released to Home Assistant
def get_supported_utilities(supports_mfa=False) -> list[type["UtilityBase"]]:
"""Return a list of all supported utilities."""
return [
Expand Down Expand Up @@ -379,7 +380,12 @@ async def _async_get_dated_data(
end_date: datetime | None = None,
) -> list[Any]:
"""Wrap _async_fetch by breaking requests for big date ranges to smaller ones to satisfy opower imposed limits."""
if aggregate_type not in SUPPORTED_AGGREGATE_TYPES.get(account.read_resolution):
# TODO: remove not None check after a Home Assistant release
if (
account.read_resolution is not None
and aggregate_type
not in SUPPORTED_AGGREGATE_TYPES.get(account.read_resolution)
):
raise ValueError(
f"Requested aggregate_type: {aggregate_type} "
f"not supported by account's read_resolution: {account.read_resolution}"
Expand Down

0 comments on commit 71f8015

Please sign in to comment.