Fix ZHA serialization issue with warning devices (#96275)

* Bump ZHA dependencies

* Update unit tests to reduce mocks
This commit is contained in:
puddly
2023-07-11 14:09:52 -04:00
committed by GitHub
parent 7e686db4be
commit b6e83be6f9
4 changed files with 68 additions and 32 deletions

View File

@ -25,10 +25,10 @@
"pyserial-asyncio==0.6",
"zha-quirks==0.0.101",
"zigpy-deconz==0.21.0",
"zigpy==0.56.1",
"zigpy==0.56.2",
"zigpy-xbee==0.18.1",
"zigpy-zigate==0.11.0",
"zigpy-znp==0.11.2"
"zigpy-znp==0.11.3"
],
"usb": [
{

View File

@ -2759,10 +2759,10 @@ zigpy-xbee==0.18.1
zigpy-zigate==0.11.0
# homeassistant.components.zha
zigpy-znp==0.11.2
zigpy-znp==0.11.3
# homeassistant.components.zha
zigpy==0.56.1
zigpy==0.56.2
# homeassistant.components.zoneminder
zm-py==0.5.2

View File

@ -2023,10 +2023,10 @@ zigpy-xbee==0.18.1
zigpy-zigate==0.11.0
# homeassistant.components.zha
zigpy-znp==0.11.2
zigpy-znp==0.11.3
# homeassistant.components.zha
zigpy==0.56.1
zigpy==0.56.2
# homeassistant.components.zwave_js
zwave-js-server-python==0.49.0

View File

@ -1,10 +1,11 @@
"""Test zha siren."""
from datetime import timedelta
from unittest.mock import patch
from unittest.mock import ANY, call, patch
import pytest
from zigpy.const import SIG_EP_PROFILE
import zigpy.profiles.zha as zha
import zigpy.zcl
import zigpy.zcl.clusters.general as general
import zigpy.zcl.clusters.security as security
import zigpy.zcl.foundation as zcl_f
@ -85,48 +86,76 @@ async def test_siren(hass: HomeAssistant, siren) -> None:
# turn on from HA
with patch(
"zigpy.zcl.Cluster.request",
"zigpy.device.Device.request",
return_value=mock_coro([0x00, zcl_f.Status.SUCCESS]),
), patch(
"zigpy.zcl.Cluster.request",
side_effect=zigpy.zcl.Cluster.request,
autospec=True,
):
# turn on via UI
await hass.services.async_call(
SIREN_DOMAIN, "turn_on", {"entity_id": entity_id}, blocking=True
)
assert len(cluster.request.mock_calls) == 1
assert cluster.request.call_args[0][0] is False
assert cluster.request.call_args[0][1] == 0
assert cluster.request.call_args[0][3] == 50 # bitmask for default args
assert cluster.request.call_args[0][4] == 5 # duration in seconds
assert cluster.request.call_args[0][5] == 0
assert cluster.request.call_args[0][6] == 2
assert cluster.request.mock_calls == [
call(
cluster,
False,
0,
ANY,
50, # bitmask for default args
5, # duration in seconds
0,
2,
manufacturer=None,
expect_reply=True,
tsn=None,
)
]
# test that the state has changed to on
assert hass.states.get(entity_id).state == STATE_ON
# turn off from HA
with patch(
"zigpy.zcl.Cluster.request",
"zigpy.device.Device.request",
return_value=mock_coro([0x01, zcl_f.Status.SUCCESS]),
), patch(
"zigpy.zcl.Cluster.request",
side_effect=zigpy.zcl.Cluster.request,
autospec=True,
):
# turn off via UI
await hass.services.async_call(
SIREN_DOMAIN, "turn_off", {"entity_id": entity_id}, blocking=True
)
assert len(cluster.request.mock_calls) == 1
assert cluster.request.call_args[0][0] is False
assert cluster.request.call_args[0][1] == 0
assert cluster.request.call_args[0][3] == 2 # bitmask for default args
assert cluster.request.call_args[0][4] == 5 # duration in seconds
assert cluster.request.call_args[0][5] == 0
assert cluster.request.call_args[0][6] == 2
assert cluster.request.mock_calls == [
call(
cluster,
False,
0,
ANY,
2, # bitmask for default args
5, # duration in seconds
0,
2,
manufacturer=None,
expect_reply=True,
tsn=None,
)
]
# test that the state has changed to off
assert hass.states.get(entity_id).state == STATE_OFF
# turn on from HA
with patch(
"zigpy.zcl.Cluster.request",
"zigpy.device.Device.request",
return_value=mock_coro([0x00, zcl_f.Status.SUCCESS]),
), patch(
"zigpy.zcl.Cluster.request",
side_effect=zigpy.zcl.Cluster.request,
autospec=True,
):
# turn on via UI
await hass.services.async_call(
@ -140,14 +169,21 @@ async def test_siren(hass: HomeAssistant, siren) -> None:
},
blocking=True,
)
assert len(cluster.request.mock_calls) == 1
assert cluster.request.call_args[0][0] is False
assert cluster.request.call_args[0][1] == 0
assert cluster.request.call_args[0][3] == 97 # bitmask for passed args
assert cluster.request.call_args[0][4] == 10 # duration in seconds
assert cluster.request.call_args[0][5] == 0
assert cluster.request.call_args[0][6] == 2
assert cluster.request.mock_calls == [
call(
cluster,
False,
0,
ANY,
97, # bitmask for passed args
10, # duration in seconds
0,
2,
manufacturer=None,
expect_reply=True,
tsn=None,
)
]
# test that the state has changed to on
assert hass.states.get(entity_id).state == STATE_ON