@@ -155,34 +155,6 @@ async def async_step_pick_firmware(
155155 description_placeholders = self ._get_translation_placeholders (),
156156 )
157157
158- async def _probe_firmware_info (
159- self ,
160- probe_methods : tuple [ApplicationType , ...] = (
161- # We probe in order of frequency: Zigbee, Thread, then multi-PAN
162- ApplicationType .GECKO_BOOTLOADER ,
163- ApplicationType .EZSP ,
164- ApplicationType .SPINEL ,
165- ApplicationType .CPC ,
166- ),
167- ) -> bool :
168- """Probe the firmware currently on the device."""
169- assert self ._device is not None
170-
171- self ._probed_firmware_info = await probe_silabs_firmware_info (
172- self ._device ,
173- probe_methods = probe_methods ,
174- )
175-
176- return (
177- self ._probed_firmware_info is not None
178- and self ._probed_firmware_info .firmware_type
179- in (
180- ApplicationType .EZSP ,
181- ApplicationType .SPINEL ,
182- ApplicationType .CPC ,
183- )
184- )
185-
186158 async def _install_firmware_step (
187159 self ,
188160 fw_update_url : str ,
@@ -236,12 +208,6 @@ async def _install_firmware(
236208 expected_installed_firmware_type : ApplicationType ,
237209 ) -> None :
238210 """Install firmware."""
239- if not await self ._probe_firmware_info ():
240- raise AbortFlow (
241- reason = "unsupported_firmware" ,
242- description_placeholders = self ._get_translation_placeholders (),
243- )
244-
245211 assert self ._device is not None
246212
247213 # Keep track of the firmware we're working with, for error messages
@@ -250,6 +216,8 @@ async def _install_firmware(
250216 # Installing new firmware is only truly required if the wrong type is
251217 # installed: upgrading to the latest release of the current firmware type
252218 # isn't strictly necessary for functionality.
219+ self ._probed_firmware_info = await probe_silabs_firmware_info (self ._device )
220+
253221 firmware_install_required = self ._probed_firmware_info is None or (
254222 self ._probed_firmware_info .firmware_type != expected_installed_firmware_type
255223 )
@@ -301,7 +269,7 @@ async def _install_firmware(
301269 # Otherwise, fail
302270 raise AbortFlow (reason = "firmware_download_failed" ) from err
303271
304- await async_flash_silabs_firmware (
272+ self . _probed_firmware_info = await async_flash_silabs_firmware (
305273 hass = self .hass ,
306274 device = self ._device ,
307275 fw_data = fw_data ,
@@ -314,15 +282,6 @@ async def _install_firmware(
314282
315283 async def _configure_and_start_otbr_addon (self ) -> None :
316284 """Configure and start the OTBR addon."""
317-
318- # Before we start the addon, confirm that the correct firmware is running
319- # and populate `self._probed_firmware_info` with the correct information
320- if not await self ._probe_firmware_info (probe_methods = (ApplicationType .SPINEL ,)):
321- raise AbortFlow (
322- "unsupported_firmware" ,
323- description_placeholders = self ._get_translation_placeholders (),
324- )
325-
326285 otbr_manager = get_otbr_addon_manager (self .hass )
327286 addon_info = await self ._async_get_addon_info (otbr_manager )
328287
@@ -444,12 +403,12 @@ async def _async_continue_picked_firmware(self) -> ConfigFlowResult:
444403 if self ._picked_firmware_type == PickedFirmwareType .ZIGBEE :
445404 return await self .async_step_install_zigbee_firmware ()
446405
447- return await self .async_step_prepare_thread_installation ()
406+ return await self .async_step_install_thread_firmware ()
448407
449- async def async_step_prepare_thread_installation (
408+ async def async_step_finish_thread_installation (
450409 self , user_input : dict [str , Any ] | None = None
451410 ) -> ConfigFlowResult :
452- """Prepare for Thread installation by stopping the OTBR addon if needed ."""
411+ """Finish Thread installation by starting the OTBR addon."""
453412 if not is_hassio (self .hass ):
454413 return self .async_abort (
455414 reason = "not_hassio_thread" ,
@@ -459,22 +418,12 @@ async def async_step_prepare_thread_installation(
459418 otbr_manager = get_otbr_addon_manager (self .hass )
460419 addon_info = await self ._async_get_addon_info (otbr_manager )
461420
462- if addon_info .state == AddonState .RUNNING :
463- # Stop the addon before continuing to flash firmware
464- await otbr_manager .async_stop_addon ()
465-
466- return await self .async_step_install_thread_firmware ()
467-
468- async def async_step_finish_thread_installation (
469- self , user_input : dict [str , Any ] | None = None
470- ) -> ConfigFlowResult :
471- """Finish Thread installation by starting the OTBR addon."""
472- otbr_manager = get_otbr_addon_manager (self .hass )
473- addon_info = await self ._async_get_addon_info (otbr_manager )
474-
475421 if addon_info .state == AddonState .NOT_INSTALLED :
476422 return await self .async_step_install_otbr_addon ()
477423
424+ if addon_info .state == AddonState .RUNNING :
425+ await otbr_manager .async_stop_addon ()
426+
478427 return await self .async_step_start_otbr_addon ()
479428
480429 async def async_step_pick_firmware_zigbee (
@@ -511,12 +460,6 @@ async def async_step_continue_zigbee(
511460 assert self ._device is not None
512461 assert self ._hardware_name is not None
513462
514- if not await self ._probe_firmware_info (probe_methods = (ApplicationType .EZSP ,)):
515- return self .async_abort (
516- reason = "unsupported_firmware" ,
517- description_placeholders = self ._get_translation_placeholders (),
518- )
519-
520463 if self ._zigbee_integration == ZigbeeIntegration .OTHER :
521464 return self ._async_flow_finished ()
522465
0 commit comments