Skip to content

Commit e253ccc

Browse files
committed
Do not wait for CONNECTED state when resetting
1 parent 469b765 commit e253ccc

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

tests/test_network_state.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import zigpy_deconz
1313
import zigpy_deconz.api
1414
import zigpy_deconz.exception
15+
import zigpy_deconz.types
1516
import zigpy_deconz.zigbee.application as application
1617

1718
from tests.async_mock import AsyncMock, patch
@@ -428,5 +429,7 @@ async def write_parameter(param, *args):
428429
for mock_call in app._api.write_parameter.mock_calls
429430
)
430431

431-
# Verify network state changes were called
432-
assert len(app._change_network_state.mock_calls) == 2
432+
# Verify network state changes were awaited
433+
assert app._change_network_state.mock_calls == [
434+
call(zigpy_deconz.api.NetworkState.OFFLINE)
435+
]

zigpy_deconz/zigbee/application.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,14 @@ async def write_network_info(self, *, network_info, node_info):
313313
# Note: Changed network configuration parameters become only affective after
314314
# sending a Leave Network Request followed by a Create or Join Network Request
315315
await self._change_network_state(NetworkState.OFFLINE)
316+
317+
if (
318+
network_info.pan_id == 0xFFFF
319+
or network_info.channel_mask == zigpy.types.Channels(0)
320+
):
321+
# Network is being reset, it will never enter the CONNECTED state
322+
return
323+
316324
await asyncio.sleep(CHANGE_NETWORK_STATE_DELAY)
317325
await self._change_network_state(NetworkState.CONNECTED)
318326

0 commit comments

Comments
 (0)