mirror of
https://github.com/home-assistant/core.git
synced 2025-07-30 18:58:04 +02:00
Fix ZHA serialization issue with warning devices (#96275)
* Bump ZHA dependencies * Update unit tests to reduce mocks
This commit is contained in:
@ -25,10 +25,10 @@
|
|||||||
"pyserial-asyncio==0.6",
|
"pyserial-asyncio==0.6",
|
||||||
"zha-quirks==0.0.101",
|
"zha-quirks==0.0.101",
|
||||||
"zigpy-deconz==0.21.0",
|
"zigpy-deconz==0.21.0",
|
||||||
"zigpy==0.56.1",
|
"zigpy==0.56.2",
|
||||||
"zigpy-xbee==0.18.1",
|
"zigpy-xbee==0.18.1",
|
||||||
"zigpy-zigate==0.11.0",
|
"zigpy-zigate==0.11.0",
|
||||||
"zigpy-znp==0.11.2"
|
"zigpy-znp==0.11.3"
|
||||||
],
|
],
|
||||||
"usb": [
|
"usb": [
|
||||||
{
|
{
|
||||||
|
@ -2759,10 +2759,10 @@ zigpy-xbee==0.18.1
|
|||||||
zigpy-zigate==0.11.0
|
zigpy-zigate==0.11.0
|
||||||
|
|
||||||
# homeassistant.components.zha
|
# homeassistant.components.zha
|
||||||
zigpy-znp==0.11.2
|
zigpy-znp==0.11.3
|
||||||
|
|
||||||
# homeassistant.components.zha
|
# homeassistant.components.zha
|
||||||
zigpy==0.56.1
|
zigpy==0.56.2
|
||||||
|
|
||||||
# homeassistant.components.zoneminder
|
# homeassistant.components.zoneminder
|
||||||
zm-py==0.5.2
|
zm-py==0.5.2
|
||||||
|
@ -2023,10 +2023,10 @@ zigpy-xbee==0.18.1
|
|||||||
zigpy-zigate==0.11.0
|
zigpy-zigate==0.11.0
|
||||||
|
|
||||||
# homeassistant.components.zha
|
# homeassistant.components.zha
|
||||||
zigpy-znp==0.11.2
|
zigpy-znp==0.11.3
|
||||||
|
|
||||||
# homeassistant.components.zha
|
# homeassistant.components.zha
|
||||||
zigpy==0.56.1
|
zigpy==0.56.2
|
||||||
|
|
||||||
# homeassistant.components.zwave_js
|
# homeassistant.components.zwave_js
|
||||||
zwave-js-server-python==0.49.0
|
zwave-js-server-python==0.49.0
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
"""Test zha siren."""
|
"""Test zha siren."""
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from unittest.mock import patch
|
from unittest.mock import ANY, call, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from zigpy.const import SIG_EP_PROFILE
|
from zigpy.const import SIG_EP_PROFILE
|
||||||
import zigpy.profiles.zha as zha
|
import zigpy.profiles.zha as zha
|
||||||
|
import zigpy.zcl
|
||||||
import zigpy.zcl.clusters.general as general
|
import zigpy.zcl.clusters.general as general
|
||||||
import zigpy.zcl.clusters.security as security
|
import zigpy.zcl.clusters.security as security
|
||||||
import zigpy.zcl.foundation as zcl_f
|
import zigpy.zcl.foundation as zcl_f
|
||||||
@ -85,48 +86,76 @@ async def test_siren(hass: HomeAssistant, siren) -> None:
|
|||||||
|
|
||||||
# turn on from HA
|
# turn on from HA
|
||||||
with patch(
|
with patch(
|
||||||
"zigpy.zcl.Cluster.request",
|
"zigpy.device.Device.request",
|
||||||
return_value=mock_coro([0x00, zcl_f.Status.SUCCESS]),
|
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
|
# turn on via UI
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
SIREN_DOMAIN, "turn_on", {"entity_id": entity_id}, blocking=True
|
SIREN_DOMAIN, "turn_on", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(cluster.request.mock_calls) == 1
|
assert cluster.request.mock_calls == [
|
||||||
assert cluster.request.call_args[0][0] is False
|
call(
|
||||||
assert cluster.request.call_args[0][1] == 0
|
cluster,
|
||||||
assert cluster.request.call_args[0][3] == 50 # bitmask for default args
|
False,
|
||||||
assert cluster.request.call_args[0][4] == 5 # duration in seconds
|
0,
|
||||||
assert cluster.request.call_args[0][5] == 0
|
ANY,
|
||||||
assert cluster.request.call_args[0][6] == 2
|
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
|
# test that the state has changed to on
|
||||||
assert hass.states.get(entity_id).state == STATE_ON
|
assert hass.states.get(entity_id).state == STATE_ON
|
||||||
|
|
||||||
# turn off from HA
|
# turn off from HA
|
||||||
with patch(
|
with patch(
|
||||||
"zigpy.zcl.Cluster.request",
|
"zigpy.device.Device.request",
|
||||||
return_value=mock_coro([0x01, zcl_f.Status.SUCCESS]),
|
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
|
# turn off via UI
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
SIREN_DOMAIN, "turn_off", {"entity_id": entity_id}, blocking=True
|
SIREN_DOMAIN, "turn_off", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(cluster.request.mock_calls) == 1
|
assert cluster.request.mock_calls == [
|
||||||
assert cluster.request.call_args[0][0] is False
|
call(
|
||||||
assert cluster.request.call_args[0][1] == 0
|
cluster,
|
||||||
assert cluster.request.call_args[0][3] == 2 # bitmask for default args
|
False,
|
||||||
assert cluster.request.call_args[0][4] == 5 # duration in seconds
|
0,
|
||||||
assert cluster.request.call_args[0][5] == 0
|
ANY,
|
||||||
assert cluster.request.call_args[0][6] == 2
|
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
|
# test that the state has changed to off
|
||||||
assert hass.states.get(entity_id).state == STATE_OFF
|
assert hass.states.get(entity_id).state == STATE_OFF
|
||||||
|
|
||||||
# turn on from HA
|
# turn on from HA
|
||||||
with patch(
|
with patch(
|
||||||
"zigpy.zcl.Cluster.request",
|
"zigpy.device.Device.request",
|
||||||
return_value=mock_coro([0x00, zcl_f.Status.SUCCESS]),
|
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
|
# turn on via UI
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
@ -140,14 +169,21 @@ async def test_siren(hass: HomeAssistant, siren) -> None:
|
|||||||
},
|
},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert len(cluster.request.mock_calls) == 1
|
assert cluster.request.mock_calls == [
|
||||||
assert cluster.request.call_args[0][0] is False
|
call(
|
||||||
assert cluster.request.call_args[0][1] == 0
|
cluster,
|
||||||
assert cluster.request.call_args[0][3] == 97 # bitmask for passed args
|
False,
|
||||||
assert cluster.request.call_args[0][4] == 10 # duration in seconds
|
0,
|
||||||
assert cluster.request.call_args[0][5] == 0
|
ANY,
|
||||||
assert cluster.request.call_args[0][6] == 2
|
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
|
# test that the state has changed to on
|
||||||
assert hass.states.get(entity_id).state == STATE_ON
|
assert hass.states.get(entity_id).state == STATE_ON
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user