mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
parent
c9fd27555c
commit
a391f0a7cc
@ -5,18 +5,16 @@ import logging
|
|||||||
from types import MappingProxyType
|
from types import MappingProxyType
|
||||||
from typing import Any, cast
|
from typing import Any, cast
|
||||||
|
|
||||||
import aiohttp
|
|
||||||
from opower import (
|
from opower import (
|
||||||
Account,
|
Account,
|
||||||
AggregateType,
|
AggregateType,
|
||||||
CannotConnect,
|
|
||||||
CostRead,
|
CostRead,
|
||||||
Forecast,
|
Forecast,
|
||||||
InvalidAuth,
|
|
||||||
MeterType,
|
MeterType,
|
||||||
Opower,
|
Opower,
|
||||||
ReadResolution,
|
ReadResolution,
|
||||||
)
|
)
|
||||||
|
from opower.exceptions import ApiException, CannotConnect, InvalidAuth
|
||||||
|
|
||||||
from homeassistant.components.recorder import get_instance
|
from homeassistant.components.recorder import get_instance
|
||||||
from homeassistant.components.recorder.models import StatisticData, StatisticMetaData
|
from homeassistant.components.recorder.models import StatisticData, StatisticMetaData
|
||||||
@ -89,7 +87,7 @@ class OpowerCoordinator(DataUpdateCoordinator[dict[str, Forecast]]):
|
|||||||
raise UpdateFailed(f"Error during login: {err}") from err
|
raise UpdateFailed(f"Error during login: {err}") from err
|
||||||
try:
|
try:
|
||||||
forecasts: list[Forecast] = await self.api.async_get_forecast()
|
forecasts: list[Forecast] = await self.api.async_get_forecast()
|
||||||
except aiohttp.ClientError as err:
|
except ApiException as err:
|
||||||
_LOGGER.error("Error getting forecasts: %s", err)
|
_LOGGER.error("Error getting forecasts: %s", err)
|
||||||
raise
|
raise
|
||||||
_LOGGER.debug("Updating sensor data with: %s", forecasts)
|
_LOGGER.debug("Updating sensor data with: %s", forecasts)
|
||||||
@ -102,7 +100,7 @@ class OpowerCoordinator(DataUpdateCoordinator[dict[str, Forecast]]):
|
|||||||
"""Insert Opower statistics."""
|
"""Insert Opower statistics."""
|
||||||
try:
|
try:
|
||||||
accounts = await self.api.async_get_accounts()
|
accounts = await self.api.async_get_accounts()
|
||||||
except aiohttp.ClientError as err:
|
except ApiException as err:
|
||||||
_LOGGER.error("Error getting accounts: %s", err)
|
_LOGGER.error("Error getting accounts: %s", err)
|
||||||
raise
|
raise
|
||||||
for account in accounts:
|
for account in accounts:
|
||||||
@ -271,7 +269,7 @@ class OpowerCoordinator(DataUpdateCoordinator[dict[str, Forecast]]):
|
|||||||
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
|
||||||
)
|
)
|
||||||
except aiohttp.ClientError as err:
|
except ApiException as err:
|
||||||
_LOGGER.error("Error getting monthly cost reads: %s", err)
|
_LOGGER.error("Error getting monthly cost reads: %s", err)
|
||||||
raise
|
raise
|
||||||
_LOGGER.debug("Got %s monthly cost reads", len(cost_reads))
|
_LOGGER.debug("Got %s monthly cost reads", len(cost_reads))
|
||||||
@ -290,7 +288,7 @@ class OpowerCoordinator(DataUpdateCoordinator[dict[str, Forecast]]):
|
|||||||
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
|
||||||
)
|
)
|
||||||
except aiohttp.ClientError as err:
|
except ApiException as err:
|
||||||
_LOGGER.error("Error getting daily cost reads: %s", err)
|
_LOGGER.error("Error getting daily cost reads: %s", err)
|
||||||
raise
|
raise
|
||||||
_LOGGER.debug("Got %s daily cost reads", len(daily_cost_reads))
|
_LOGGER.debug("Got %s daily cost reads", len(daily_cost_reads))
|
||||||
@ -308,7 +306,7 @@ class OpowerCoordinator(DataUpdateCoordinator[dict[str, Forecast]]):
|
|||||||
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
|
||||||
)
|
)
|
||||||
except aiohttp.ClientError as err:
|
except ApiException as err:
|
||||||
_LOGGER.error("Error getting hourly cost reads: %s", err)
|
_LOGGER.error("Error getting hourly cost reads: %s", err)
|
||||||
raise
|
raise
|
||||||
_LOGGER.debug("Got %s hourly cost reads", len(hourly_cost_reads))
|
_LOGGER.debug("Got %s hourly cost reads", len(hourly_cost_reads))
|
||||||
|
@ -7,5 +7,5 @@
|
|||||||
"documentation": "https://www.home-assistant.io/integrations/opower",
|
"documentation": "https://www.home-assistant.io/integrations/opower",
|
||||||
"iot_class": "cloud_polling",
|
"iot_class": "cloud_polling",
|
||||||
"loggers": ["opower"],
|
"loggers": ["opower"],
|
||||||
"requirements": ["opower==0.8.8"]
|
"requirements": ["opower==0.8.9"]
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ ELEC_SENSORS: tuple[OpowerEntityDescription, ...] = (
|
|||||||
device_class=SensorDeviceClass.DATE,
|
device_class=SensorDeviceClass.DATE,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
value_fn=lambda data: data.start_date,
|
value_fn=lambda data: str(data.start_date),
|
||||||
),
|
),
|
||||||
OpowerEntityDescription(
|
OpowerEntityDescription(
|
||||||
key="elec_end_date",
|
key="elec_end_date",
|
||||||
@ -105,7 +105,7 @@ ELEC_SENSORS: tuple[OpowerEntityDescription, ...] = (
|
|||||||
device_class=SensorDeviceClass.DATE,
|
device_class=SensorDeviceClass.DATE,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
value_fn=lambda data: data.end_date,
|
value_fn=lambda data: str(data.end_date),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
GAS_SENSORS: tuple[OpowerEntityDescription, ...] = (
|
GAS_SENSORS: tuple[OpowerEntityDescription, ...] = (
|
||||||
@ -169,7 +169,7 @@ GAS_SENSORS: tuple[OpowerEntityDescription, ...] = (
|
|||||||
device_class=SensorDeviceClass.DATE,
|
device_class=SensorDeviceClass.DATE,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
value_fn=lambda data: data.start_date,
|
value_fn=lambda data: str(data.start_date),
|
||||||
),
|
),
|
||||||
OpowerEntityDescription(
|
OpowerEntityDescription(
|
||||||
key="gas_end_date",
|
key="gas_end_date",
|
||||||
@ -177,7 +177,7 @@ GAS_SENSORS: tuple[OpowerEntityDescription, ...] = (
|
|||||||
device_class=SensorDeviceClass.DATE,
|
device_class=SensorDeviceClass.DATE,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
value_fn=lambda data: data.end_date,
|
value_fn=lambda data: str(data.end_date),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
2
requirements_all.txt
generated
2
requirements_all.txt
generated
@ -1592,7 +1592,7 @@ openwrt-luci-rpc==1.1.17
|
|||||||
openwrt-ubus-rpc==0.0.2
|
openwrt-ubus-rpc==0.0.2
|
||||||
|
|
||||||
# homeassistant.components.opower
|
# homeassistant.components.opower
|
||||||
opower==0.8.8
|
opower==0.8.9
|
||||||
|
|
||||||
# homeassistant.components.oralb
|
# homeassistant.components.oralb
|
||||||
oralb-ble==0.17.6
|
oralb-ble==0.17.6
|
||||||
|
2
requirements_test_all.txt
generated
2
requirements_test_all.txt
generated
@ -1328,7 +1328,7 @@ openhomedevice==2.2.0
|
|||||||
openwebifpy==4.3.1
|
openwebifpy==4.3.1
|
||||||
|
|
||||||
# homeassistant.components.opower
|
# homeassistant.components.opower
|
||||||
opower==0.8.8
|
opower==0.8.9
|
||||||
|
|
||||||
# homeassistant.components.oralb
|
# homeassistant.components.oralb
|
||||||
oralb-ble==0.17.6
|
oralb-ble==0.17.6
|
||||||
|
Loading…
x
Reference in New Issue
Block a user