diff --git a/tests/test_application.py b/tests/test_application.py index 68297e0..0f645d2 100644 --- a/tests/test_application.py +++ b/tests/test_application.py @@ -1,4 +1,4 @@ -from unittest.mock import AsyncMock, MagicMock, patch, sentinel +from unittest.mock import AsyncMock, MagicMock, patch, sentinel, call import pytest import logging @@ -178,3 +178,24 @@ async def test_send_group_request(app): await app.send_packet(packet) app._api.raw_aps_data_request.assert_called_once() + + +@pytest.mark.asyncio +async def test_energy_scanning(app, caplog): + with caplog.at_level(logging.WARNING): + scan_results = await app.energy_scan(channels=zigpy_t.Channels.ALL_CHANNELS, duration_exp=2, count=5) + + assert scan_results == {c: 0 for c in zigpy_t.Channels.ALL_CHANNELS} + + # We never send a request when scanning + assert len(app._api.raw_aps_data_request.mock_calls) == 0 + + assert "does not support energy scanning" in caplog.text + + +@pytest.mark.asyncio +async def test_channel_migration(app, caplog): + app._api.set_channel = AsyncMock() + await app._move_network_to_channel(17, new_nwk_update_id=2) + + assert app._api.set_channel.mock_calls == [call(17)] diff --git a/zigpy_zigate/__init__.py b/zigpy_zigate/__init__.py index 9c80242..74b0df0 100644 --- a/zigpy_zigate/__init__.py +++ b/zigpy_zigate/__init__.py @@ -1,5 +1,5 @@ MAJOR_VERSION = 0 -MINOR_VERSION = 10 -PATCH_VERSION = '3' +MINOR_VERSION = 11 +PATCH_VERSION = '0' __short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION) __version__ = '{}.{}'.format(__short_version__, PATCH_VERSION) diff --git a/zigpy_zigate/zigbee/application.py b/zigpy_zigate/zigbee/application.py index 374b581..9592db5 100644 --- a/zigpy_zigate/zigbee/application.py +++ b/zigpy_zigate/zigbee/application.py @@ -154,6 +154,20 @@ async def write_network_info(self, *, network_info, node_info): async def permit_with_key(self, node, code, time_s = 60): LOGGER.warning("ZiGate does not support joins with install codes") + async def _move_network_to_channel( + self, new_channel: int, *, new_nwk_update_id: int + ) -> None: + """Moves the network to a new channel.""" + await self._api.set_channel(new_channel) + + async def energy_scan( + self, channels: zigpy.types.Channels, duration_exp: int, count: int + ) -> dict[int, float]: + """Runs an energy detection scan and returns the per-channel scan results.""" + + LOGGER.warning("Coordinator does not support energy scanning") + return {c: 0 for c in channels} + async def force_remove(self, dev): await self._api.remove_device(self.state.node_info.ieee, dev.ieee)