1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Clarify behavior of ConfigEntry.async_on_state_change (#151628)

This commit is contained in:
Erik Montnemery
2025-09-03 17:21:28 +02:00
committed by GitHub
parent b9f24bbb2a
commit e67df73c4e
2 changed files with 69 additions and 1 deletions

View File

@@ -1178,7 +1178,13 @@ class ConfigEntry[_DataT = Any]:
@callback
def async_on_state_change(self, func: CALLBACK_TYPE) -> CALLBACK_TYPE:
"""Add a function to call when a config entry changes its state."""
"""Add a function to call when a config entry changes its state.
Note: async_on_unload listeners are called before the state is changed to
NOT_LOADED when unloading a config entry. This means the passed function
will not be called after a config entry has been unloaded, the last call
will be after the state is changed to UNLOAD_IN_PROGRESS.
"""
if self._on_state_change is None:
self._on_state_change = []
self._on_state_change.append(func)