Skip to content
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
23 changes: 22 additions & 1 deletion tests/test_application.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)]
4 changes: 2 additions & 2 deletions zigpy_zigate/__init__.py
Original file line number Diff line number Diff line change
@@ -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)
14 changes: 14 additions & 0 deletions zigpy_zigate/zigbee/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down