Skip to content

Commit

Permalink
Syncup with zigpy==0.37.0 changes (#84)
Browse files Browse the repository at this point in the history
* Syncup with zigpy==0.37.0 changes

* Update tests
  • Loading branch information
Adminiuga authored Aug 26, 2021
1 parent 466ceb6 commit d6af52e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
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

0 comments on commit d6af52e

Please sign in to comment.