mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +00:00
Call backup listener during setup in Google Drive (#137789)
This commit is contained in:
parent
60d966f06f
commit
f3aeca5a71
@ -7,7 +7,7 @@ from collections.abc import Callable
|
|||||||
from google_drive_api.exceptions import GoogleDriveApiError
|
from google_drive_api.exceptions import GoogleDriveApiError
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.exceptions import ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryNotReady
|
||||||
from homeassistant.helpers import instance_id
|
from homeassistant.helpers import instance_id
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
@ -49,6 +49,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: GoogleDriveConfigEntry)
|
|||||||
except GoogleDriveApiError as err:
|
except GoogleDriveApiError as err:
|
||||||
raise ConfigEntryNotReady from err
|
raise ConfigEntryNotReady from err
|
||||||
|
|
||||||
|
_async_notify_backup_listeners_soon(hass)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
@ -56,10 +58,15 @@ async def async_unload_entry(
|
|||||||
hass: HomeAssistant, entry: GoogleDriveConfigEntry
|
hass: HomeAssistant, entry: GoogleDriveConfigEntry
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
hass.loop.call_soon(_notify_backup_listeners, hass)
|
_async_notify_backup_listeners_soon(hass)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def _notify_backup_listeners(hass: HomeAssistant) -> None:
|
def _async_notify_backup_listeners(hass: HomeAssistant) -> None:
|
||||||
for listener in hass.data.get(DATA_BACKUP_AGENT_LISTENERS, []):
|
for listener in hass.data.get(DATA_BACKUP_AGENT_LISTENERS, []):
|
||||||
listener()
|
listener()
|
||||||
|
|
||||||
|
|
||||||
|
@callback
|
||||||
|
def _async_notify_backup_listeners_soon(hass: HomeAssistant) -> None:
|
||||||
|
hass.loop.call_soon(_async_notify_backup_listeners, hass)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user