Fix Invalid statistic_id for Opower: National Grid (#144243)

Co-authored-by: J. Nick Koston <nick+github@koston.org>
This commit is contained in:
tronikos 2025-05-05 02:35:32 -07:00 committed by GitHub
parent 58906008b9
commit 66b2e06cd3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -113,14 +113,16 @@ class OpowerCoordinator(DataUpdateCoordinator[dict[str, Forecast]]):
_LOGGER.error("Error getting accounts: %s", err)
raise
for account in accounts:
id_prefix = "_".join(
id_prefix = (
(
self.api.utility.subdomain(),
account.meter_type.name.lower(),
# Some utilities like AEP have "-" in their account id.
# Replace it with "_" to avoid "Invalid statistic_id"
account.utility_account_id.replace("-", "_").lower(),
f"{self.api.utility.subdomain()}_{account.meter_type.name}_"
f"{account.utility_account_id}"
)
# Some utilities like AEP have "-" in their account id.
# Other utilities like ngny-gas have "-" in their subdomain.
# Replace it with "_" to avoid "Invalid statistic_id"
.replace("-", "_")
.lower()
)
cost_statistic_id = f"{DOMAIN}:{id_prefix}_energy_cost"
compensation_statistic_id = f"{DOMAIN}:{id_prefix}_energy_compensation"