async def startup(self, auto_form=False): """Perform a complete application startup""" self._api = Deconz(self, self._config[zigpy.config.CONF_DEVICE]) await self._api.connect() self.version = await self._api.version() await self._api.device_state() (ieee, ) = await self._api[NetworkParameter.mac_address] self._ieee = zigpy.types.EUI64(ieee) await self._api[NetworkParameter.nwk_panid] await self._api[NetworkParameter.nwk_address] await self._api[NetworkParameter.nwk_extended_panid] await self._api[NetworkParameter.channel_mask] await self._api[NetworkParameter.aps_extended_panid] await self._api[NetworkParameter.trust_center_address] await self._api[NetworkParameter.security_mode] await self._api[NetworkParameter.current_channel] await self._api[NetworkParameter.protocol_version] await self._api[NetworkParameter.nwk_update_id] self._api[NetworkParameter.aps_designed_coordinator] = 1 if self._api.protocol_version >= PROTO_VER_WATCHDOG: asyncio.ensure_future(self._reset_watchdog()) if auto_form: await self.form_network() self.devices[self.ieee] = await DeconzDevice.new( self, self.ieee, self.nwk, self.version, self._config[zigpy.config.CONF_DEVICE][ zigpy.config.CONF_DEVICE_PATH], )
async def startup(self, auto_form=False): """Perform a complete application startup.""" self._api = Deconz(self, self._config[zigpy.config.CONF_DEVICE]) await self._api.connect() self.version = await self._api.version() await self._api.device_state() (ieee,) = await self._api[NetworkParameter.mac_address] self._ieee = zigpy.types.EUI64(ieee) if self._api.protocol_version >= PROTO_VER_WATCHDOG: asyncio.ensure_future(self._reset_watchdog()) (designed_coord,) = await self._api[NetworkParameter.aps_designed_coordinator] device_state, _, _ = await self._api.device_state() should_form = ( device_state.network_state != NetworkState.CONNECTED or designed_coord != 1 ) if auto_form and should_form: await self.form_network() (self._pan_id,) = await self._api[NetworkParameter.nwk_panid] (self._nwk,) = await self._api[NetworkParameter.nwk_address] (self._ext_pan_id,) = await self._api[NetworkParameter.nwk_extended_panid] await self._api[NetworkParameter.channel_mask] await self._api[NetworkParameter.aps_extended_panid] await self._api[NetworkParameter.trust_center_address] await self._api[NetworkParameter.security_mode] (self._channel,) = await self._api[NetworkParameter.current_channel] await self._api[NetworkParameter.protocol_version] (self._nwk_update_id,) = await self._api[NetworkParameter.nwk_update_id] coordinator = await DeconzDevice.new( self, self.ieee, self.nwk, self.version, self._config[zigpy.config.CONF_DEVICE][zigpy.config.CONF_DEVICE_PATH], ) coordinator.neighbors.add_context_listener(self._dblistener) self.devices[self.ieee] = coordinator if self._api.protocol_version >= PROTO_VER_NEIGBOURS: await self.restore_neighbours() asyncio.create_task(self._delayed_neighbour_scan())
def app(database_file=None): return ControllerApplication(Deconz(), database_file=database_file)
async def connect(self): api = Deconz(self, self._config[zigpy.config.CONF_DEVICE]) await api.connect() self.version = await api.version() self._api = api self._written_endpoints.clear()
def app(monkeypatch, database_file=None): app = application.ControllerApplication(Deconz(), database_file=database_file) return app