diff --git a/homeassistant/components/opower/coordinator.py b/homeassistant/components/opower/coordinator.py index 6de11bb467f7b2dabfc673210fc99940c65a97bc..94a56bb19222a252cd8a4fc8288bbd949d110922 100644 --- a/homeassistant/components/opower/coordinator.py +++ b/homeassistant/components/opower/coordinator.py @@ -86,7 +86,7 @@ class OpowerCoordinator(DataUpdateCoordinator[dict[str, Forecast]]): # Because Opower provides historical usage/cost with a delay of a couple of days # we need to insert data into statistics. await self._insert_statistics() - return {forecast.account.id: forecast for forecast in forecasts} + return {forecast.account.utility_account_id: forecast for forecast in forecasts} async def _insert_statistics(self) -> None: """Insert Opower statistics.""" @@ -97,7 +97,7 @@ class OpowerCoordinator(DataUpdateCoordinator[dict[str, Forecast]]): account.meter_type.name.lower(), # Some utilities like AEP have "-" in their account id. # Replace it with "_" to avoid "Invalid statistic_id" - account.id.replace("-", "_"), + account.utility_account_id.replace("-", "_"), ) ) cost_statistic_id = f"{DOMAIN}:{id_prefix}_energy_cost" @@ -161,7 +161,7 @@ class OpowerCoordinator(DataUpdateCoordinator[dict[str, Forecast]]): name_prefix = ( f"Opower {self.api.utility.subdomain()} " - f"{account.meter_type.name.lower()} {account.id}" + f"{account.meter_type.name.lower()} {account.utility_account_id}" ) cost_metadata = StatisticMetaData( has_mean=False, diff --git a/homeassistant/components/opower/manifest.json b/homeassistant/components/opower/manifest.json index cabb4eb5360c505bf7aef6dce846c804e6f1aa1a..91e4fbc960c855c1fcf567d014dbb722f90050fc 100644 --- a/homeassistant/components/opower/manifest.json +++ b/homeassistant/components/opower/manifest.json @@ -7,5 +7,5 @@ "documentation": "https://www.home-assistant.io/integrations/opower", "iot_class": "cloud_polling", "loggers": ["opower"], - "requirements": ["opower==0.4.5"] + "requirements": ["opower==0.4.4"] } diff --git a/homeassistant/components/opower/sensor.py b/homeassistant/components/opower/sensor.py index f0c814922c52cf7e21de6ed6ae1bfd2ef663aab8..c75ffb9614b1572fbc6608f973d1e3264af61dec 100644 --- a/homeassistant/components/opower/sensor.py +++ b/homeassistant/components/opower/sensor.py @@ -159,10 +159,10 @@ async def async_setup_entry( entities: list[OpowerSensor] = [] forecasts = coordinator.data.values() for forecast in forecasts: - device_id = f"{coordinator.api.utility.subdomain()}_{forecast.account.id}" + device_id = f"{coordinator.api.utility.subdomain()}_{forecast.account.utility_account_id}" device = DeviceInfo( identifiers={(DOMAIN, device_id)}, - name=f"{forecast.account.meter_type.name} account {forecast.account.id}", + name=f"{forecast.account.meter_type.name} account {forecast.account.utility_account_id}", manufacturer="Opower", model=coordinator.api.utility.name(), entry_type=DeviceEntryType.SERVICE, @@ -182,7 +182,7 @@ async def async_setup_entry( OpowerSensor( coordinator, sensor, - forecast.account.id, + forecast.account.utility_account_id, device, device_id, ) @@ -201,7 +201,7 @@ class OpowerSensor(CoordinatorEntity[OpowerCoordinator], SensorEntity): self, coordinator: OpowerCoordinator, description: OpowerEntityDescription, - id: str, + utility_account_id: str, device: DeviceInfo, device_id: str, ) -> None: @@ -210,11 +210,13 @@ class OpowerSensor(CoordinatorEntity[OpowerCoordinator], SensorEntity): self.entity_description = description self._attr_unique_id = f"{device_id}_{description.key}" self._attr_device_info = device - self.id = id + self.utility_account_id = utility_account_id @property def native_value(self) -> StateType: """Return the state.""" if self.coordinator.data is not None: - return self.entity_description.value_fn(self.coordinator.data[self.id]) + return self.entity_description.value_fn( + self.coordinator.data[self.utility_account_id] + ) return None diff --git a/requirements_all.txt b/requirements_all.txt index bc1457cd3742b62942f5eff877bce61995e1970f..80591a046ace0b38a3c1e3ca3a2765227c83b972 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1495,7 +1495,7 @@ openwrt-luci-rpc==1.1.17 openwrt-ubus-rpc==0.0.2 # homeassistant.components.opower -opower==0.4.5 +opower==0.4.4 # homeassistant.components.oralb oralb-ble==0.17.6 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 06e7ae8fd30e00d1789a5f25c90907728ea1b93b..245b45606b23e35164dbbf3bed34e07e24bbb3d1 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1195,7 +1195,7 @@ openhomedevice==2.2.0 openwebifpy==4.2.4 # homeassistant.components.opower -opower==0.4.5 +opower==0.4.4 # homeassistant.components.oralb oralb-ble==0.17.6