1
mirror of https://github.com/home-assistant/core synced 2024-08-02 23:40:32 +02:00
ha-core/homeassistant/components/zha/backup.py
puddly 8e2f0497ce
ZHA network backup and restore API (#75791)
* Implement WS API endpoints for zigpy backups

* Implement backup restoration

* Display error messages caused by invalid backup JSON

* Indicate to the frontend when a backup is incomplete

* Perform a coordinator backup before HA performs a backup

* Fix `backup.async_post_backup` docstring

* Rename `data` to `backup` in restore command

* Add unit tests for new websocket APIs

* Unit test backup platform

* Move code to overwrite EZSP EUI64 into ZHA

* Include the radio type in the network settings API response
2022-07-28 11:24:31 -04:00

22 lines
660 B
Python

"""Backup platform for the ZHA integration."""
import logging
from homeassistant.core import HomeAssistant
from .core import ZHAGateway
from .core.const import DATA_ZHA, DATA_ZHA_GATEWAY
_LOGGER = logging.getLogger(__name__)
async def async_pre_backup(hass: HomeAssistant) -> None:
"""Perform operations before a backup starts."""
_LOGGER.debug("Performing coordinator backup")
zha_gateway: ZHAGateway = hass.data[DATA_ZHA][DATA_ZHA_GATEWAY]
await zha_gateway.application_controller.backups.create_backup(load_devices=True)
async def async_post_backup(hass: HomeAssistant) -> None:
"""Perform operations after a backup finishes."""