Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ZHA serialization issue with warning devices #96275

Merged
merged 2 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions homeassistant/components/zha/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down
4 changes: 2 additions & 2 deletions requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
88 changes: 62 additions & 26 deletions tests/components/zha/test_siren.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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

Expand Down