Skip to content

Commit

Permalink
Bump ZHA dependencies (#128539)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
puddly and TheJulianJES authored Oct 17, 2024
1 parent 72f1c35 commit f6270d9
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 29 deletions.
5 changes: 0 additions & 5 deletions homeassistant/components/zha/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()}
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/zha/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
38 changes: 19 additions & 19 deletions tests/components/zha/test_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand All @@ -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
),
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
)
Expand All @@ -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,
Expand Down Expand Up @@ -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
)

Expand All @@ -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
),
Expand All @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit f6270d9

Please sign in to comment.