mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Add config entry remove callback (#21576)
This commit is contained in:
committed by
Paulus Schoutsen
parent
cd6c923123
commit
0903bd92f0
@@ -378,6 +378,17 @@ class ConfigEntry:
|
||||
self.state = ENTRY_STATE_FAILED_UNLOAD
|
||||
return False
|
||||
|
||||
async def async_remove(self, hass: HomeAssistant) -> None:
|
||||
"""Invoke remove callback on component."""
|
||||
component = getattr(hass.components, self.domain)
|
||||
if not hasattr(component, 'async_remove_entry'):
|
||||
return
|
||||
try:
|
||||
await component.async_remove_entry(hass, self)
|
||||
except Exception: # pylint: disable=broad-except
|
||||
_LOGGER.exception('Error calling entry remove callback %s for %s',
|
||||
self.title, component.DOMAIN)
|
||||
|
||||
async def async_migrate(self, hass: HomeAssistant) -> bool:
|
||||
"""Migrate an entry.
|
||||
|
||||
@@ -499,6 +510,8 @@ class ConfigEntries:
|
||||
else:
|
||||
unload_success = await self.async_unload(entry_id)
|
||||
|
||||
await entry.async_remove(self.hass)
|
||||
|
||||
self._entries.remove(entry)
|
||||
self._async_schedule_save()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user