1212import zigpy .endpoint
1313import zigpy .exceptions
1414import zigpy .neighbor
15+ import zigpy .state
1516import zigpy .types
1617import zigpy .util
1718
@@ -66,7 +67,7 @@ async def startup(self, auto_form=False):
6667 self .version = await self ._api .version ()
6768 await self ._api .device_state ()
6869 (ieee ,) = await self ._api [NetworkParameter .mac_address ]
69- self ._ieee = zigpy .types .EUI64 (ieee )
70+ self .state . node_information . ieee = zigpy .types .EUI64 (ieee )
7071
7172 if self ._api .protocol_version >= PROTO_VER_WATCHDOG :
7273 asyncio .ensure_future (self ._reset_watchdog ())
@@ -79,16 +80,34 @@ async def startup(self, auto_form=False):
7980 if auto_form and should_form :
8081 await self .form_network ()
8182
82- (self ._pan_id ,) = await self ._api [NetworkParameter .nwk_panid ]
83- (self ._nwk ,) = await self ._api [NetworkParameter .nwk_address ]
84- (self ._ext_pan_id ,) = await self ._api [NetworkParameter .nwk_extended_panid ]
85- await self ._api [NetworkParameter .channel_mask ]
83+ (self .state .node_information .nwk ,) = await self ._api [
84+ NetworkParameter .nwk_address
85+ ]
86+ (self .state .network_information .pan_id ,) = await self ._api [
87+ NetworkParameter .nwk_panid
88+ ]
89+ (self .state .network_information .extended_pan_id ,) = await self ._api [
90+ NetworkParameter .nwk_extended_panid
91+ ]
92+ (self .state .network_information .channel_mask ,) = await self ._api [
93+ NetworkParameter .channel_mask
94+ ]
8695 await self ._api [NetworkParameter .aps_extended_panid ]
87- await self ._api [NetworkParameter .trust_center_address ]
88- await self ._api [NetworkParameter .security_mode ]
89- (self ._channel ,) = await self ._api [NetworkParameter .current_channel ]
96+ if self .state .network_information .tc_link_key is None :
97+ self .state .network_information .tc_link_key = zigpy .state .Key ()
98+ (self .state .network_information .tc_link_key .partner_ieee ,) = await self ._api [
99+ NetworkParameter .trust_center_address
100+ ]
101+ (self .state .network_information .security_level ,) = await self ._api [
102+ NetworkParameter .security_mode
103+ ]
104+ (self .state .network_information .channel ,) = await self ._api [
105+ NetworkParameter .current_channel
106+ ]
90107 await self ._api [NetworkParameter .protocol_version ]
91- (self ._nwk_update_id ,) = await self ._api [NetworkParameter .nwk_update_id ]
108+ (self .state .network_information .nwk_update_id ,) = await self ._api [
109+ NetworkParameter .nwk_update_id
110+ ]
92111
93112 coordinator = await DeconzDevice .new (
94113 self ,
@@ -434,6 +453,6 @@ async def new(cls, application, ieee, nwk, version: int, device_path: str):
434453 ep .out_clusters = from_ep .out_clusters
435454 else :
436455 application .devices [ieee ] = dev
437- await dev ._initialize ()
456+ await dev .initialize ()
438457
439458 return dev
0 commit comments