Repository event subscription (#67284)
This commit is contained in:
parent
73fdd47d54
commit
e65670fef4
5 changed files with 61 additions and 7 deletions
|
@ -38,6 +38,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
)
|
||||
|
||||
await coordinator.async_config_entry_first_refresh()
|
||||
await coordinator.subscribe()
|
||||
|
||||
hass.data[DOMAIN][repository] = coordinator
|
||||
|
||||
|
@ -45,7 +46,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
|
||||
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||
entry.async_on_unload(entry.add_update_listener(async_reload_entry))
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
@ -77,6 +77,10 @@ def async_cleanup_device_registry(
|
|||
|
||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Unload a config entry."""
|
||||
repositories: dict[str, GitHubDataUpdateCoordinator] = hass.data[DOMAIN]
|
||||
for coordinator in repositories.values():
|
||||
coordinator.unsubscribe()
|
||||
|
||||
if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
|
||||
hass.data.pop(DOMAIN)
|
||||
return unload_ok
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue