Skip to content

Commit 99e307f

Browse files
authored
Bump opower to 0.8.9 (#136911)
* Bump opower to 0.8.9 * mypy
1 parent 4d4e11a commit 99e307f

5 files changed

Lines changed: 13 additions & 15 deletions

File tree

homeassistant/components/opower/coordinator.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,16 @@
55
from types import MappingProxyType
66
from typing import Any, cast
77

8-
import aiohttp
98
from opower import (
109
Account,
1110
AggregateType,
12-
CannotConnect,
1311
CostRead,
1412
Forecast,
15-
InvalidAuth,
1613
MeterType,
1714
Opower,
1815
ReadResolution,
1916
)
17+
from opower.exceptions import ApiException, CannotConnect, InvalidAuth
2018

2119
from homeassistant.components.recorder import get_instance
2220
from homeassistant.components.recorder.models import StatisticData, StatisticMetaData
@@ -89,7 +87,7 @@ async def _async_update_data(
8987
raise UpdateFailed(f"Error during login: {err}") from err
9088
try:
9189
forecasts: list[Forecast] = await self.api.async_get_forecast()
92-
except aiohttp.ClientError as err:
90+
except ApiException as err:
9391
_LOGGER.error("Error getting forecasts: %s", err)
9492
raise
9593
_LOGGER.debug("Updating sensor data with: %s", forecasts)
@@ -102,7 +100,7 @@ async def _insert_statistics(self) -> None:
102100
"""Insert Opower statistics."""
103101
try:
104102
accounts = await self.api.async_get_accounts()
105-
except aiohttp.ClientError as err:
103+
except ApiException as err:
106104
_LOGGER.error("Error getting accounts: %s", err)
107105
raise
108106
for account in accounts:
@@ -271,7 +269,7 @@ def _update_with_finer_cost_reads(
271269
cost_reads = await self.api.async_get_cost_reads(
272270
account, AggregateType.BILL, start, end
273271
)
274-
except aiohttp.ClientError as err:
272+
except ApiException as err:
275273
_LOGGER.error("Error getting monthly cost reads: %s", err)
276274
raise
277275
_LOGGER.debug("Got %s monthly cost reads", len(cost_reads))
@@ -290,7 +288,7 @@ def _update_with_finer_cost_reads(
290288
daily_cost_reads = await self.api.async_get_cost_reads(
291289
account, AggregateType.DAY, start, end
292290
)
293-
except aiohttp.ClientError as err:
291+
except ApiException as err:
294292
_LOGGER.error("Error getting daily cost reads: %s", err)
295293
raise
296294
_LOGGER.debug("Got %s daily cost reads", len(daily_cost_reads))
@@ -308,7 +306,7 @@ def _update_with_finer_cost_reads(
308306
hourly_cost_reads = await self.api.async_get_cost_reads(
309307
account, AggregateType.HOUR, start, end
310308
)
311-
except aiohttp.ClientError as err:
309+
except ApiException as err:
312310
_LOGGER.error("Error getting hourly cost reads: %s", err)
313311
raise
314312
_LOGGER.debug("Got %s hourly cost reads", len(hourly_cost_reads))

homeassistant/components/opower/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
"documentation": "https://www.home-assistant.io/integrations/opower",
88
"iot_class": "cloud_polling",
99
"loggers": ["opower"],
10-
"requirements": ["opower==0.8.8"]
10+
"requirements": ["opower==0.8.9"]
1111
}

homeassistant/components/opower/sensor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,15 @@ class OpowerEntityDescription(SensorEntityDescription):
9797
device_class=SensorDeviceClass.DATE,
9898
entity_category=EntityCategory.DIAGNOSTIC,
9999
entity_registry_enabled_default=False,
100-
value_fn=lambda data: data.start_date,
100+
value_fn=lambda data: str(data.start_date),
101101
),
102102
OpowerEntityDescription(
103103
key="elec_end_date",
104104
name="Current bill electric end date",
105105
device_class=SensorDeviceClass.DATE,
106106
entity_category=EntityCategory.DIAGNOSTIC,
107107
entity_registry_enabled_default=False,
108-
value_fn=lambda data: data.end_date,
108+
value_fn=lambda data: str(data.end_date),
109109
),
110110
)
111111
GAS_SENSORS: tuple[OpowerEntityDescription, ...] = (
@@ -169,15 +169,15 @@ class OpowerEntityDescription(SensorEntityDescription):
169169
device_class=SensorDeviceClass.DATE,
170170
entity_category=EntityCategory.DIAGNOSTIC,
171171
entity_registry_enabled_default=False,
172-
value_fn=lambda data: data.start_date,
172+
value_fn=lambda data: str(data.start_date),
173173
),
174174
OpowerEntityDescription(
175175
key="gas_end_date",
176176
name="Current bill gas end date",
177177
device_class=SensorDeviceClass.DATE,
178178
entity_category=EntityCategory.DIAGNOSTIC,
179179
entity_registry_enabled_default=False,
180-
value_fn=lambda data: data.end_date,
180+
value_fn=lambda data: str(data.end_date),
181181
),
182182
)
183183

requirements_all.txt

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

requirements_test_all.txt

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)