Move runtime_data deletion after unload (#119224)
* Move runtime_data deletion after unload. Doing this before unload means we can't use, eg. the coordinator, during teardown. * Re-order config entry on unload * Add test --------- Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
parent
3308f07d4b
commit
9bb9792607
2 changed files with 17 additions and 10 deletions
|
@ -803,13 +803,13 @@ class ConfigEntry(Generic[_DataT]):
|
|||
assert isinstance(result, bool)
|
||||
|
||||
# Only adjust state if we unloaded the component
|
||||
if domain_is_integration:
|
||||
if result:
|
||||
self._async_set_state(hass, ConfigEntryState.NOT_LOADED, None)
|
||||
if hasattr(self, "runtime_data"):
|
||||
object.__delattr__(self, "runtime_data")
|
||||
|
||||
if domain_is_integration and result:
|
||||
await self._async_process_on_unload(hass)
|
||||
if hasattr(self, "runtime_data"):
|
||||
object.__delattr__(self, "runtime_data")
|
||||
|
||||
self._async_set_state(hass, ConfigEntryState.NOT_LOADED, None)
|
||||
|
||||
except Exception as exc:
|
||||
_LOGGER.exception(
|
||||
"Error unloading entry %s for %s", self.title, integration.domain
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue