@@ -237,8 +237,8 @@ async def setup(self, discover: bool = True, load: bool = True) -> None:
237237 if not self .is_connected :
238238 await self .connect ()
239239 if not self .is_initialized :
240- await self .initialize ()
241- if discover :
240+ initialized = await self .initialize ()
241+ if initialized and discover :
242242 await self .start_network ()
243243 await self .discover_coordinator ()
244244 await self .discover_nodes ()
@@ -271,9 +271,13 @@ async def plus_pair_request(self, mac: str) -> bool:
271271 return await self ._controller .pair_plus_device (mac )
272272
273273 @raise_not_connected
274- async def initialize (self , create_root_cache_folder : bool = False ) -> None :
274+ async def initialize (self , create_root_cache_folder : bool = False ) -> bool :
275275 """Initialize connection to USB-Stick."""
276276 await self ._controller .initialize_stick ()
277+ # Check if network is offline = StickInitShortResponse
278+ if self ._controller .mac_coordinator is None :
279+ return False
280+
277281 if self ._network is None :
278282 self ._network = StickNetwork (self ._controller )
279283 self ._network .cache_folder = self ._cache_folder
@@ -282,6 +286,8 @@ async def initialize(self, create_root_cache_folder: bool = False) -> None:
282286 if self ._cache_enabled :
283287 await self ._network .initialize_cache ()
284288
289+ return True
290+
285291 @raise_not_connected
286292 @raise_not_initialized
287293 async def start_network (self ) -> None :
0 commit comments