mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
* Revert "Clear statistics when you unload the Opower integration (#135908)" This reverts commit aa19207ea4a12abc592781baeff674027ece33dd. * Fix OpowerConfigEntry imports * Re-add entry type hint to coordinator
This commit is contained in:
parent
49968904b2
commit
7678f8fddd
@ -64,7 +64,6 @@ class OpowerCoordinator(DataUpdateCoordinator[dict[str, Forecast]]):
|
|||||||
config_entry.data[CONF_PASSWORD],
|
config_entry.data[CONF_PASSWORD],
|
||||||
config_entry.data.get(CONF_TOTP_SECRET),
|
config_entry.data.get(CONF_TOTP_SECRET),
|
||||||
)
|
)
|
||||||
self._statistic_ids: set[str] = set()
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _dummy_listener() -> None:
|
def _dummy_listener() -> None:
|
||||||
@ -76,12 +75,6 @@ class OpowerCoordinator(DataUpdateCoordinator[dict[str, Forecast]]):
|
|||||||
# _async_update_data not periodically getting called which is needed for _insert_statistics.
|
# _async_update_data not periodically getting called which is needed for _insert_statistics.
|
||||||
self.async_add_listener(_dummy_listener)
|
self.async_add_listener(_dummy_listener)
|
||||||
|
|
||||||
self.config_entry.async_on_unload(self._clear_statistics)
|
|
||||||
|
|
||||||
def _clear_statistics(self) -> None:
|
|
||||||
"""Clear statistics."""
|
|
||||||
get_instance(self.hass).async_clear_statistics(list(self._statistic_ids))
|
|
||||||
|
|
||||||
async def _async_update_data(
|
async def _async_update_data(
|
||||||
self,
|
self,
|
||||||
) -> dict[str, Forecast]:
|
) -> dict[str, Forecast]:
|
||||||
@ -127,8 +120,6 @@ class OpowerCoordinator(DataUpdateCoordinator[dict[str, Forecast]]):
|
|||||||
)
|
)
|
||||||
cost_statistic_id = f"{DOMAIN}:{id_prefix}_energy_cost"
|
cost_statistic_id = f"{DOMAIN}:{id_prefix}_energy_cost"
|
||||||
consumption_statistic_id = f"{DOMAIN}:{id_prefix}_energy_consumption"
|
consumption_statistic_id = f"{DOMAIN}:{id_prefix}_energy_consumption"
|
||||||
self._statistic_ids.add(cost_statistic_id)
|
|
||||||
self._statistic_ids.add(consumption_statistic_id)
|
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Updating Statistics for %s and %s",
|
"Updating Statistics for %s and %s",
|
||||||
cost_statistic_id,
|
cost_statistic_id,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user