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

Fix config entry _async_process_on_unload being called for forwarded platforms (#117084)

This commit is contained in:
J. Nick Koston
2024-05-08 16:59:37 -05:00
committed by GitHub
parent ac9b8cce37
commit 89049bc022
3 changed files with 13 additions and 6 deletions

View File

@@ -753,7 +753,7 @@ class ConfigEntry(Generic[_DataT]):
component = await integration.async_get_component()
if integration.domain == self.domain:
if domain_is_integration := self.domain == integration.domain:
if not self.state.recoverable:
return False
@@ -765,7 +765,7 @@ class ConfigEntry(Generic[_DataT]):
supports_unload = hasattr(component, "async_unload_entry")
if not supports_unload:
if integration.domain == self.domain:
if domain_is_integration:
self._async_set_state(
hass, ConfigEntryState.FAILED_UNLOAD, "Unload not supported"
)
@@ -777,15 +777,16 @@ class ConfigEntry(Generic[_DataT]):
assert isinstance(result, bool)
# Only adjust state if we unloaded the component
if result and integration.domain == self.domain:
self._async_set_state(hass, ConfigEntryState.NOT_LOADED, None)
if domain_is_integration:
if result:
self._async_set_state(hass, ConfigEntryState.NOT_LOADED, None)
await self._async_process_on_unload(hass)
await self._async_process_on_unload(hass)
except Exception as exc:
_LOGGER.exception(
"Error unloading entry %s for %s", self.title, integration.domain
)
if integration.domain == self.domain:
if domain_is_integration:
self._async_set_state(
hass, ConfigEntryState.FAILED_UNLOAD, str(exc) or "Unknown error"
)