Skip to content

Commit 0a53ce9

Browse files
committed
Network: collect channel info
1 parent 413364a commit 0a53ce9

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

plugwise_usb/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ def cache_enabled(self, enable: bool = True) -> None:
9191
self._network.cache_enabled = enable
9292
self._cache_enabled = enable
9393

94+
@property
95+
def channel(self) -> int | None:
96+
"""Zigbee channel number."""
97+
return self._network.channel
98+
9499
@property
95100
def nodes(self) -> dict[str, PlugwiseNode]:
96101
"""Dictionary with all discovered and supported plugwise devices with the MAC address as their key."""

plugwise_usb/network/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def __init__(
5959
self._cache_enabled: bool = False
6060
self._cache_folder_create = False
6161

62+
self._channel: int | None = None
6263
self._discover: bool = False
6364
self._nodes: dict[str, PlugwiseNode] = {}
6465
self._awake_discovery: dict[str, datetime] = {}
@@ -126,6 +127,11 @@ async def initialize_cache(self) -> None:
126127
raise CacheError("Unable to initialize cache, enable cache first.")
127128
await self._register.initialize_cache(self._cache_folder_create)
128129

130+
@property
131+
def channel(self) -> int | None:
132+
"""Zigbee channel number."""
133+
return self._channel
134+
129135
@property
130136
def controller_active(self) -> bool:
131137
"""Return True if network controller (Circle+) is discovered and active."""
@@ -342,6 +348,11 @@ async def discover_network_coordinator(self, load: bool = False) -> bool:
342348
if ping_response is None:
343349
return False
344350

351+
# Collect network info
352+
request = StickNetworkInfoRequest(self._controller.send)
353+
if (network_info := await request.send()) is not None:
354+
self._channel = network_info.channel
355+
345356
if await self._discover_node(
346357
self._controller.mac_coordinator, None, ping_first=False
347358
):

0 commit comments

Comments
 (0)