Home Assistant Unofficial Reference 2024.12.1
backup.py
Go to the documentation of this file.
1 """Backup platform for the ZHA integration."""
2 
3 import logging
4 
5 from homeassistant.core import HomeAssistant
6 
7 from .helpers import get_zha_gateway
8 
9 _LOGGER = logging.getLogger(__name__)
10 
11 
12 async def async_pre_backup(hass: HomeAssistant) -> None:
13  """Perform operations before a backup starts."""
14  _LOGGER.debug("Performing coordinator backup")
15 
16  try:
17  zha_gateway = get_zha_gateway(hass)
18  except ValueError:
19  # If ZHA config is in `configuration.yaml` and ZHA is not set up, do nothing
20  _LOGGER.warning("No ZHA gateway exists, skipping coordinator backup")
21  return
22 
23  await zha_gateway.application_controller.backups.create_backup(load_devices=True)
24 
25 
26 async def async_post_backup(hass: HomeAssistant) -> None:
27  """Perform operations after a backup finishes."""
None async_post_backup(HomeAssistant hass)
Definition: backup.py:26
None async_pre_backup(HomeAssistant hass)
Definition: backup.py:12
Gateway get_zha_gateway(HomeAssistant hass)
Definition: helpers.py:1028