Skip to content

Commit 123fc7d

Browse files
authored
Merge pull request #145 from puddly/rc
0.11.0 Release
2 parents 606dfc9 + 88cbf50 commit 123fc7d

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed

tests/test_application.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from unittest.mock import AsyncMock, MagicMock, patch, sentinel
1+
from unittest.mock import AsyncMock, MagicMock, patch, sentinel, call
22

33
import pytest
44
import logging
@@ -178,3 +178,24 @@ async def test_send_group_request(app):
178178
await app.send_packet(packet)
179179

180180
app._api.raw_aps_data_request.assert_called_once()
181+
182+
183+
@pytest.mark.asyncio
184+
async def test_energy_scanning(app, caplog):
185+
with caplog.at_level(logging.WARNING):
186+
scan_results = await app.energy_scan(channels=zigpy_t.Channels.ALL_CHANNELS, duration_exp=2, count=5)
187+
188+
assert scan_results == {c: 0 for c in zigpy_t.Channels.ALL_CHANNELS}
189+
190+
# We never send a request when scanning
191+
assert len(app._api.raw_aps_data_request.mock_calls) == 0
192+
193+
assert "does not support energy scanning" in caplog.text
194+
195+
196+
@pytest.mark.asyncio
197+
async def test_channel_migration(app, caplog):
198+
app._api.set_channel = AsyncMock()
199+
await app._move_network_to_channel(17, new_nwk_update_id=2)
200+
201+
assert app._api.set_channel.mock_calls == [call(17)]

zigpy_zigate/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
MAJOR_VERSION = 0
2-
MINOR_VERSION = 10
3-
PATCH_VERSION = '3'
2+
MINOR_VERSION = 11
3+
PATCH_VERSION = '0'
44
__short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION)
55
__version__ = '{}.{}'.format(__short_version__, PATCH_VERSION)

zigpy_zigate/zigbee/application.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,20 @@ async def write_network_info(self, *, network_info, node_info):
154154
async def permit_with_key(self, node, code, time_s = 60):
155155
LOGGER.warning("ZiGate does not support joins with install codes")
156156

157+
async def _move_network_to_channel(
158+
self, new_channel: int, *, new_nwk_update_id: int
159+
) -> None:
160+
"""Moves the network to a new channel."""
161+
await self._api.set_channel(new_channel)
162+
163+
async def energy_scan(
164+
self, channels: zigpy.types.Channels, duration_exp: int, count: int
165+
) -> dict[int, float]:
166+
"""Runs an energy detection scan and returns the per-channel scan results."""
167+
168+
LOGGER.warning("Coordinator does not support energy scanning")
169+
return {c: 0 for c in channels}
170+
157171
async def force_remove(self, dev):
158172
await self._api.remove_device(self.state.node_info.ieee, dev.ieee)
159173

0 commit comments

Comments
 (0)