mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Stop fast polling of a Zigbee device after a check-in command (#49685)
* Stop fast polling after a check-in * Update tests
This commit is contained in:
parent
e5e71c2026
commit
4a6bb96a0f
@ -422,6 +422,7 @@ class PollControl(ZigbeeChannel):
|
|||||||
await self.checkin_response(True, self.CHECKIN_FAST_POLL_TIMEOUT, tsn=tsn)
|
await self.checkin_response(True, self.CHECKIN_FAST_POLL_TIMEOUT, tsn=tsn)
|
||||||
if self._ch_pool.manufacturer_code not in self._IGNORED_MANUFACTURER_ID:
|
if self._ch_pool.manufacturer_code not in self._IGNORED_MANUFACTURER_ID:
|
||||||
await self.set_long_poll_interval(self.LONG_POLL)
|
await self.set_long_poll_interval(self.LONG_POLL)
|
||||||
|
await self.fast_poll_stop()
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def skip_manufacturer_id(self, manufacturer_code: int) -> None:
|
def skip_manufacturer_id(self, manufacturer_code: int) -> None:
|
||||||
|
@ -445,19 +445,22 @@ async def test_poll_control_checkin_response(poll_control_ch):
|
|||||||
"""Test poll control channel checkin response."""
|
"""Test poll control channel checkin response."""
|
||||||
rsp_mock = AsyncMock()
|
rsp_mock = AsyncMock()
|
||||||
set_interval_mock = AsyncMock()
|
set_interval_mock = AsyncMock()
|
||||||
|
fast_poll_mock = AsyncMock()
|
||||||
cluster = poll_control_ch.cluster
|
cluster = poll_control_ch.cluster
|
||||||
patch_1 = mock.patch.object(cluster, "checkin_response", rsp_mock)
|
patch_1 = mock.patch.object(cluster, "checkin_response", rsp_mock)
|
||||||
patch_2 = mock.patch.object(cluster, "set_long_poll_interval", set_interval_mock)
|
patch_2 = mock.patch.object(cluster, "set_long_poll_interval", set_interval_mock)
|
||||||
|
patch_3 = mock.patch.object(cluster, "fast_poll_stop", fast_poll_mock)
|
||||||
|
|
||||||
with patch_1, patch_2:
|
with patch_1, patch_2, patch_3:
|
||||||
await poll_control_ch.check_in_response(33)
|
await poll_control_ch.check_in_response(33)
|
||||||
|
|
||||||
assert rsp_mock.call_count == 1
|
assert rsp_mock.call_count == 1
|
||||||
assert set_interval_mock.call_count == 1
|
assert set_interval_mock.call_count == 1
|
||||||
|
assert fast_poll_mock.call_count == 1
|
||||||
|
|
||||||
await poll_control_ch.check_in_response(33)
|
await poll_control_ch.check_in_response(33)
|
||||||
assert cluster.endpoint.request.call_count == 2
|
assert cluster.endpoint.request.call_count == 3
|
||||||
assert cluster.endpoint.request.await_count == 2
|
assert cluster.endpoint.request.await_count == 3
|
||||||
assert cluster.endpoint.request.call_args_list[0][0][1] == 33
|
assert cluster.endpoint.request.call_args_list[0][0][1] == 33
|
||||||
assert cluster.endpoint.request.call_args_list[0][0][0] == 0x0020
|
assert cluster.endpoint.request.call_args_list[0][0][0] == 0x0020
|
||||||
assert cluster.endpoint.request.call_args_list[1][0][0] == 0x0020
|
assert cluster.endpoint.request.call_args_list[1][0][0] == 0x0020
|
||||||
|
Loading…
x
Reference in New Issue
Block a user