Skip to content

Syncup with zigpy==0.37.0 changes #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 26, 2021
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
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
install_requires=[
'pyserial-asyncio; platform_system!="Windows"',
'pyserial-asyncio!=0.5; platform_system=="Windows"', # 0.5 broke writes
"zigpy>=0.34.0",
"zigpy>=0.37.0",
"async_timeout",
"voluptuous",
"coloredlogs",
Expand Down
4 changes: 2 additions & 2 deletions tests/application/test_startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ async def test_info(
app, znp_server = make_application(server_cls=device)

# These should not raise any errors even if our NIB is empty
assert app.pan_id is None
assert app.extended_pan_id is None
assert app.pan_id == 0xFFFE # unknown NWK ID
assert app.extended_pan_id == t.EUI64.convert("ff:ff:ff:ff:ff:ff:ff:ff")
assert app.channel is None
assert app.channels is None
assert app.network_key is None
Expand Down
36 changes: 23 additions & 13 deletions zigpy_znp/zigbee/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import zigpy.zdo
import zigpy.util
import zigpy.state
import zigpy.types
import zigpy.config
import zigpy.device
Expand Down Expand Up @@ -120,8 +121,6 @@ def __init__(self, config: conf.ConfigType):
self._watchdog_task = asyncio.Future()
self._watchdog_task.cancel()

self._network_key = None
self._network_key_seq = None
self._version_rsp = None
self._concurrent_requests_semaphore = None
self._currently_waiting_requests = 0
Expand All @@ -135,12 +134,16 @@ def __init__(self, config: conf.ConfigType):
@property
def network_key(self) -> t.KeyData | None:
# This is not a standard Zigpy property
return self._network_key
if self.state.network_information.network_key:
return self.state.network_information.network_key.key
return None

@property
def network_key_seq(self) -> t.uint8_t | None:
# This is not a standard Zigpy property
return self._network_key_seq
if self.state.network_information.network_key:
return self.state.network_information.network_key.seq
return None

@classmethod
async def probe(cls, device_config: conf.ConfigType) -> bool:
Expand Down Expand Up @@ -1279,15 +1282,22 @@ async def _load_network_info(self) -> None:

await self._znp.load_network_info()

self._ieee = self._znp.network_info.ieee
self._nwk = self._znp.network_info.nwk
self._channel = self._znp.network_info.channel
self._channels = self._znp.network_info.channels
self._pan_id = self._znp.network_info.pan_id
self._ext_pan_id = self._znp.network_info.extended_pan_id
self._nwk_update_id = self._znp.network_info.nwk_update_id
self._network_key = self._znp.network_info.network_key
self._network_key_seq = self._znp.network_info.network_key_seq
self.ieee = self._znp.network_info.ieee
self.nwk = self._znp.network_info.nwk
self.state.network_information.channel = self._znp.network_info.channel
self.state.network_information.channel_mask = self._znp.network_info.channels
self.state.network_information.pan_id = self._znp.network_info.pan_id
self.state.network_information.extended_pan_id = (
self._znp.network_info.extended_pan_id
)
self.state.network_information.nwk_update_id = (
self._znp.network_info.nwk_update_id
)
nwk_key = zigpy.state.Key(
key=self._znp.network_info.network_key,
seq=self._znp.network_info.network_key_seq,
)
self.state.network_information.network_key = nwk_key

def _find_endpoint(self, dst_ep: int, profile: int, cluster: int) -> int:
"""
Expand Down