From f6270d9cfc10b710519f336fe8b1406acd32a74d Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Wed, 16 Oct 2024 22:15:00 -0400 Subject: [PATCH] Bump ZHA dependencies (#128539) * Bump ZHA dependencies * Remove unused ZHA color modes * Rename `cluster` to `ota_cluster` in update tests to unshadow `cluster` in `endpoint_reply` --------- Co-authored-by: TheJulianJES --- homeassistant/components/zha/light.py | 5 --- homeassistant/components/zha/manifest.json | 2 +- requirements_all.txt | 4 +-- requirements_test_all.txt | 4 +-- tests/components/zha/test_update.py | 38 +++++++++++----------- 5 files changed, 24 insertions(+), 29 deletions(-) diff --git a/homeassistant/components/zha/light.py b/homeassistant/components/zha/light.py index fa83ad1cab6d5f..9a22dfb02e953c 100644 --- a/homeassistant/components/zha/light.py +++ b/homeassistant/components/zha/light.py @@ -44,12 +44,7 @@ ZhaColorMode.ONOFF: ColorMode.ONOFF, ZhaColorMode.BRIGHTNESS: ColorMode.BRIGHTNESS, ZhaColorMode.COLOR_TEMP: ColorMode.COLOR_TEMP, - ZhaColorMode.HS: ColorMode.HS, ZhaColorMode.XY: ColorMode.XY, - ZhaColorMode.RGB: ColorMode.RGB, - ZhaColorMode.RGBW: ColorMode.RGBW, - ZhaColorMode.RGBWW: ColorMode.RGBWW, - ZhaColorMode.WHITE: ColorMode.WHITE, } HA_TO_ZHA_COLOR_MODE = {v: k for k, v in ZHA_TO_HA_COLOR_MODE.items()} diff --git a/homeassistant/components/zha/manifest.json b/homeassistant/components/zha/manifest.json index dd15fb99960f30..89cfa5ae738e03 100644 --- a/homeassistant/components/zha/manifest.json +++ b/homeassistant/components/zha/manifest.json @@ -21,7 +21,7 @@ "zha", "universal_silabs_flasher" ], - "requirements": ["universal-silabs-flasher==0.0.22", "zha==0.0.34"], + "requirements": ["universal-silabs-flasher==0.0.23", "zha==0.0.35"], "usb": [ { "vid": "10C4", diff --git a/requirements_all.txt b/requirements_all.txt index 35ac9f62fee623..a88b9366d595f2 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2887,7 +2887,7 @@ unifi_ap==0.0.1 unifiled==0.11 # homeassistant.components.zha -universal-silabs-flasher==0.0.22 +universal-silabs-flasher==0.0.23 # homeassistant.components.upb upb-lib==0.5.8 @@ -3053,7 +3053,7 @@ zeroconf==0.135.0 zeversolar==0.3.1 # homeassistant.components.zha -zha==0.0.34 +zha==0.0.35 # homeassistant.components.zhong_hong zhong-hong-hvac==1.0.12 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 80f4cd8a20d39a..868db56a44b6ed 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -2288,7 +2288,7 @@ ultraheat-api==0.5.7 unifi-discovery==1.2.0 # homeassistant.components.zha -universal-silabs-flasher==0.0.22 +universal-silabs-flasher==0.0.23 # homeassistant.components.upb upb-lib==0.5.8 @@ -2430,7 +2430,7 @@ zeroconf==0.135.0 zeversolar==0.3.1 # homeassistant.components.zha -zha==0.0.34 +zha==0.0.35 # homeassistant.components.zwave_js zwave-js-server-python==0.58.1 diff --git a/tests/components/zha/test_update.py b/tests/components/zha/test_update.py index e2a614915f9587..bb25f0a444dfa0 100644 --- a/tests/components/zha/test_update.py +++ b/tests/components/zha/test_update.py @@ -272,7 +272,7 @@ async def test_firmware_update_success( ) -> None: """Test ZHA update platform - firmware update success.""" await setup_zha() - zha_device, cluster, fw_image, installed_fw_version = await setup_test_data( + zha_device, ota_cluster, fw_image, installed_fw_version = await setup_test_data( hass, zigpy_device_mock ) @@ -284,7 +284,7 @@ async def test_firmware_update_success( assert hass.states.get(entity_id).state == STATE_UNKNOWN # simulate an image available notification - await cluster._handle_query_next_image( + await ota_cluster._handle_query_next_image( foundation.ZCLHeader.cluster( tsn=0x12, command_id=general.Ota.ServerCommandDefs.query_next_image.id ), @@ -306,14 +306,14 @@ async def test_firmware_update_success( attrs[ATTR_LATEST_VERSION] == f"0x{fw_image.firmware.header.file_version:08x}" ) - async def endpoint_reply(cluster_id, tsn, data, command_id): - if cluster_id == general.Ota.cluster_id: - hdr, cmd = cluster.deserialize(data) + async def endpoint_reply(cluster, sequence, data, **kwargs): + if cluster == general.Ota.cluster_id: + hdr, cmd = ota_cluster.deserialize(data) if isinstance(cmd, general.Ota.ImageNotifyCommand): zha_device.device.device.packet_received( make_packet( zha_device.device.device, - cluster, + ota_cluster, general.Ota.ServerCommandDefs.query_next_image.name, field_control=general.Ota.QueryNextImageCommand.FieldControl.HardwareVersion, manufacturer_code=fw_image.firmware.header.manufacturer_id, @@ -333,7 +333,7 @@ async def endpoint_reply(cluster_id, tsn, data, command_id): zha_device.device.device.packet_received( make_packet( zha_device.device.device, - cluster, + ota_cluster, general.Ota.ServerCommandDefs.image_block.name, field_control=general.Ota.ImageBlockCommand.FieldControl.RequestNodeAddr, manufacturer_code=fw_image.firmware.header.manufacturer_id, @@ -360,7 +360,7 @@ async def endpoint_reply(cluster_id, tsn, data, command_id): zha_device.device.device.packet_received( make_packet( zha_device.device.device, - cluster, + ota_cluster, general.Ota.ServerCommandDefs.image_block.name, field_control=general.Ota.ImageBlockCommand.FieldControl.RequestNodeAddr, manufacturer_code=fw_image.firmware.header.manufacturer_id, @@ -398,7 +398,7 @@ async def endpoint_reply(cluster_id, tsn, data, command_id): zha_device.device.device.packet_received( make_packet( zha_device.device.device, - cluster, + ota_cluster, general.Ota.ServerCommandDefs.upgrade_end.name, status=foundation.Status.SUCCESS, manufacturer_code=fw_image.firmware.header.manufacturer_id, @@ -417,7 +417,7 @@ async def endpoint_reply(cluster_id, tsn, data, command_id): assert cmd.upgrade_time == 0 def read_new_fw_version(*args, **kwargs): - cluster.update_attribute( + ota_cluster.update_attribute( attrid=general.Ota.AttributeDefs.current_file_version.id, value=fw_image.firmware.header.file_version, ) @@ -427,9 +427,9 @@ def read_new_fw_version(*args, **kwargs): ) }, {} - cluster.read_attributes.side_effect = read_new_fw_version + ota_cluster.read_attributes.side_effect = read_new_fw_version - cluster.endpoint.reply = AsyncMock(side_effect=endpoint_reply) + ota_cluster.endpoint.reply = AsyncMock(side_effect=endpoint_reply) await hass.services.async_call( UPDATE_DOMAIN, SERVICE_INSTALL, @@ -465,7 +465,7 @@ async def test_firmware_update_raises( ) -> None: """Test ZHA update platform - firmware update raises.""" await setup_zha() - zha_device, cluster, fw_image, installed_fw_version = await setup_test_data( + zha_device, ota_cluster, fw_image, installed_fw_version = await setup_test_data( hass, zigpy_device_mock ) @@ -475,7 +475,7 @@ async def test_firmware_update_raises( assert hass.states.get(entity_id).state == STATE_UNKNOWN # simulate an image available notification - await cluster._handle_query_next_image( + await ota_cluster._handle_query_next_image( foundation.ZCLHeader.cluster( tsn=0x12, command_id=general.Ota.ServerCommandDefs.query_next_image.id ), @@ -498,14 +498,14 @@ async def test_firmware_update_raises( attrs[ATTR_LATEST_VERSION] == f"0x{fw_image.firmware.header.file_version:08x}" ) - async def endpoint_reply(cluster_id, tsn, data, command_id): - if cluster_id == general.Ota.cluster_id: - hdr, cmd = cluster.deserialize(data) + async def endpoint_reply(cluster, sequence, data, **kwargs): + if cluster == general.Ota.cluster_id: + hdr, cmd = ota_cluster.deserialize(data) if isinstance(cmd, general.Ota.ImageNotifyCommand): zha_device.device.device.packet_received( make_packet( zha_device.device.device, - cluster, + ota_cluster, general.Ota.ServerCommandDefs.query_next_image.name, field_control=general.Ota.QueryNextImageCommand.FieldControl.HardwareVersion, manufacturer_code=fw_image.firmware.header.manufacturer_id, @@ -524,7 +524,7 @@ async def endpoint_reply(cluster_id, tsn, data, command_id): assert cmd.image_size == fw_image.firmware.header.image_size raise DeliveryError("failed to deliver") - cluster.endpoint.reply = AsyncMock(side_effect=endpoint_reply) + ota_cluster.endpoint.reply = AsyncMock(side_effect=endpoint_reply) with pytest.raises(HomeAssistantError): await hass.services.async_call( UPDATE_DOMAIN,