Skip to content

Commit

Permalink
Increase Zigbee command retries (home-assistant#93877)
Browse files Browse the repository at this point in the history
* Enable retries for requests

* Update unit tests

* Account for fewer group retries in unit tests
  • Loading branch information
puddly committed Jun 1, 2023
1 parent 226647f commit b9ec3a8
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@

_LOGGER = logging.getLogger(__name__)

DEFAULT_REQUEST_RETRIES = 3


class AttrReportConfig(TypedDict, total=True):
"""Configuration to report for the attributes."""
Expand Down Expand Up @@ -78,6 +80,8 @@ def decorate_command(cluster_handler, command):

@wraps(command)
async def wrapper(*args, **kwds):
kwds.setdefault("tries", DEFAULT_REQUEST_RETRIES)

try:
result = await command(*args, **kwds)
cluster_handler.debug(
Expand Down
5 changes: 5 additions & 0 deletions tests/components/zha/test_alarm_control_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ async def test_alarm_control_panel(
0,
security.IasAce.AudibleNotification.Default_Sound,
security.IasAce.AlarmStatus.No_Alarm,
tries=3,
)

# disarm from HA
Expand Down Expand Up @@ -134,6 +135,7 @@ async def test_alarm_control_panel(
0,
security.IasAce.AudibleNotification.Default_Sound,
security.IasAce.AlarmStatus.Emergency,
tries=3,
)

# reset the panel
Expand All @@ -157,6 +159,7 @@ async def test_alarm_control_panel(
0,
security.IasAce.AudibleNotification.Default_Sound,
security.IasAce.AlarmStatus.No_Alarm,
tries=3,
)

# arm_night from HA
Expand All @@ -177,6 +180,7 @@ async def test_alarm_control_panel(
0,
security.IasAce.AudibleNotification.Default_Sound,
security.IasAce.AlarmStatus.No_Alarm,
tries=3,
)

# reset the panel
Expand Down Expand Up @@ -274,5 +278,6 @@ async def reset_alarm_panel(hass, cluster, entity_id):
0,
security.IasAce.AudibleNotification.Default_Sound,
security.IasAce.AlarmStatus.No_Alarm,
tries=3,
)
cluster.client_command.reset_mock()
4 changes: 2 additions & 2 deletions tests/components/zha/test_device_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ async def test_action(hass: HomeAssistant, device_ias, device_inovelli) -> None:
5,
expect_reply=False,
manufacturer=4151,
tries=1,
tries=3,
tsn=None,
)
in cluster.request.call_args_list
Expand All @@ -345,7 +345,7 @@ async def test_action(hass: HomeAssistant, device_ias, device_inovelli) -> None:
5,
expect_reply=False,
manufacturer=4151,
tries=1,
tries=3,
tsn=None,
)
in cluster.request.call_args_list
Expand Down
2 changes: 1 addition & 1 deletion tests/components/zha/test_discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ async def test_devices(
),
expect_reply=True,
manufacturer=None,
tries=1,
tries=3,
tsn=None,
)
]
Expand Down

0 comments on commit b9ec3a8

Please sign in to comment.