From 3c012c497b622ef84fac6999c9927484764a0da4 Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Sun, 2 Jun 2024 16:55:48 -0400 Subject: [PATCH] Bump ZHA dependencies (#118658) * Bump bellows to 0.39.0 * Do not create a backup if there is no active ZHA gateway object * Bump universal-silabs-flasher as well --- homeassistant/components/zha/backup.py | 8 +++++++- homeassistant/components/zha/manifest.json | 4 ++-- requirements_all.txt | 4 ++-- requirements_test_all.txt | 4 ++-- tests/components/zha/test_backup.py | 9 ++++++++- 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/zha/backup.py b/homeassistant/components/zha/backup.py index 25d5a83b6a4..e31ae09eeb6 100644 --- a/homeassistant/components/zha/backup.py +++ b/homeassistant/components/zha/backup.py @@ -13,7 +13,13 @@ async def async_pre_backup(hass: HomeAssistant) -> None: """Perform operations before a backup starts.""" _LOGGER.debug("Performing coordinator backup") - zha_gateway = get_zha_gateway(hass) + try: + zha_gateway = get_zha_gateway(hass) + except ValueError: + # If ZHA config is in `configuration.yaml` and ZHA is not set up, do nothing + _LOGGER.warning("No ZHA gateway exists, skipping coordinator backup") + return + await zha_gateway.application_controller.backups.create_backup(load_devices=True) diff --git a/homeassistant/components/zha/manifest.json b/homeassistant/components/zha/manifest.json index 1a01ca88fd5..8caf296674c 100644 --- a/homeassistant/components/zha/manifest.json +++ b/homeassistant/components/zha/manifest.json @@ -21,7 +21,7 @@ "universal_silabs_flasher" ], "requirements": [ - "bellows==0.38.4", + "bellows==0.39.0", "pyserial==3.5", "zha-quirks==0.0.116", "zigpy-deconz==0.23.1", @@ -29,7 +29,7 @@ "zigpy-xbee==0.20.1", "zigpy-zigate==0.12.0", "zigpy-znp==0.12.1", - "universal-silabs-flasher==0.0.18", + "universal-silabs-flasher==0.0.20", "pyserial-asyncio-fast==0.11" ], "usb": [ diff --git a/requirements_all.txt b/requirements_all.txt index 3cdb44c99d5..5bf92675f53 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -547,7 +547,7 @@ beautifulsoup4==4.12.3 # beewi-smartclim==0.0.10 # homeassistant.components.zha -bellows==0.38.4 +bellows==0.39.0 # homeassistant.components.bmw_connected_drive bimmer-connected[china]==0.15.3 @@ -2794,7 +2794,7 @@ unifi_ap==0.0.1 unifiled==0.11 # homeassistant.components.zha -universal-silabs-flasher==0.0.18 +universal-silabs-flasher==0.0.20 # homeassistant.components.upb upb-lib==0.5.6 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 7591fd0a3c2..ee74a9a431d 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -472,7 +472,7 @@ base36==0.1.1 beautifulsoup4==4.12.3 # homeassistant.components.zha -bellows==0.38.4 +bellows==0.39.0 # homeassistant.components.bmw_connected_drive bimmer-connected[china]==0.15.3 @@ -2162,7 +2162,7 @@ ultraheat-api==0.5.7 unifi-discovery==1.1.8 # homeassistant.components.zha -universal-silabs-flasher==0.0.18 +universal-silabs-flasher==0.0.20 # homeassistant.components.upb upb-lib==0.5.6 diff --git a/tests/components/zha/test_backup.py b/tests/components/zha/test_backup.py index 9cf88df1707..dc6c5dc29cb 100644 --- a/tests/components/zha/test_backup.py +++ b/tests/components/zha/test_backup.py @@ -1,6 +1,6 @@ """Unit tests for ZHA backup platform.""" -from unittest.mock import AsyncMock +from unittest.mock import AsyncMock, patch from zigpy.application import ControllerApplication @@ -22,6 +22,13 @@ async def test_pre_backup( ) +@patch("homeassistant.components.zha.backup.get_zha_gateway", side_effect=ValueError()) +async def test_pre_backup_no_gateway(hass: HomeAssistant, setup_zha) -> None: + """Test graceful backup failure when no gateway exists.""" + await setup_zha() + await async_pre_backup(hass) + + async def test_post_backup(hass: HomeAssistant, setup_zha) -> None: """Test no-op `async_post_backup`.""" await setup_zha()