Skip to content
Prev Previous commit
Next Next commit
Make the probing and reset method kwargs mandatory
  • Loading branch information
puddly committed Nov 11, 2025
commit 4cc4859ad9a2a386efebf14ae1175dab506e3a5e
12 changes: 6 additions & 6 deletions homeassistant/components/homeassistant_hardware/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ async def guess_firmware_info(hass: HomeAssistant, device_path: str) -> Firmware
async def probe_silabs_firmware_info(
device: str,
*,
bootloader_reset_methods: Sequence[ResetTarget] = (),
application_probe_methods: Sequence[tuple[ApplicationType, int]] = (),
bootloader_reset_methods: Sequence[ResetTarget],
application_probe_methods: Sequence[tuple[ApplicationType, int]],
) -> FirmwareInfo | None:
"""Probe the running firmware on a SiLabs device."""
flasher = Flasher(
Expand Down Expand Up @@ -350,8 +350,8 @@ async def probe_silabs_firmware_info(
async def probe_silabs_firmware_type(
device: str,
*,
bootloader_reset_methods: Sequence[ResetTarget] = (),
application_probe_methods: Sequence[tuple[ApplicationType, int]] = (),
bootloader_reset_methods: Sequence[ResetTarget],
application_probe_methods: Sequence[tuple[ApplicationType, int]],
) -> ApplicationType | None:
"""Probe the running firmware type on a SiLabs device."""

Expand All @@ -371,8 +371,8 @@ async def async_flash_silabs_firmware(
device: str,
fw_data: bytes,
expected_installed_firmware_type: ApplicationType,
bootloader_reset_methods: Sequence[ResetTarget] = (),
application_probe_methods: Sequence[tuple[ApplicationType, int]] = (),
bootloader_reset_methods: Sequence[ResetTarget],
application_probe_methods: Sequence[tuple[ApplicationType, int]],
progress_callback: Callable[[int, int], None] | None = None,
*,
domain: str = DOMAIN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,11 @@ async def async_step_system(
assert self._device is not None

# We do not actually use any portion of `BaseFirmwareConfigFlow` beyond this
self._probed_firmware_info = await probe_silabs_firmware_info(self._device)
self._probed_firmware_info = await probe_silabs_firmware_info(
self._device,
bootloader_reset_methods=self.BOOTLOADER_RESET_METHODS,
application_probe_methods=self.APPLICATION_PROBE_METHODS,
)

# Kick off ZHA hardware discovery automatically if Zigbee firmware is running
if (
Expand Down
12 changes: 11 additions & 1 deletion homeassistant/components/zha/repairs/wrong_silabs_firmware.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,17 @@ async def warn_on_wrong_silabs_firmware(hass: HomeAssistant, device: str) -> boo
if device.startswith("socket://"):
return False

app_type = await probe_silabs_firmware_type(device)
app_type = await probe_silabs_firmware_type(
device,
bootloader_reset_methods=(),
application_probe_methods=[
(ApplicationType.GECKO_BOOTLOADER, 115200),
(ApplicationType.EZSP, 115200),
(ApplicationType.EZSP, 460800),
(ApplicationType.SPINEL, 460800),
(ApplicationType.CPC, 460800),
],
)

if app_type is None:
# Failed to probe, we can't tell if the wrong firmware is installed
Expand Down
15 changes: 13 additions & 2 deletions tests/components/homeassistant_hardware/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,11 @@ def probe_app_type() -> None:
"homeassistant.components.homeassistant_hardware.util.Flasher",
return_value=mock_flasher,
):
result = await probe_silabs_firmware_info("/dev/ttyUSB0")
result = await probe_silabs_firmware_info(
"/dev/ttyUSB0",
bootloader_reset_methods=(),
application_probe_methods=(),
)
assert result == expected_fw_info


Expand Down Expand Up @@ -531,7 +535,11 @@ async def test_probe_silabs_firmware_type(
autospec=True,
return_value=probe_result,
):
result = await probe_silabs_firmware_type("/dev/ttyUSB0")
result = await probe_silabs_firmware_type(
"/dev/ttyUSB0",
bootloader_reset_methods=(),
application_probe_methods=(),
)
assert result == expected


Expand Down Expand Up @@ -597,6 +605,7 @@ async def mock_flash_firmware(
fw_data=b"firmware contents",
expected_installed_firmware_type=ApplicationType.SPINEL,
bootloader_reset_methods=(),
application_probe_methods=(),
progress_callback=progress_callback,
)

Expand Down Expand Up @@ -660,6 +669,7 @@ async def test_async_flash_silabs_firmware_flash_failure(hass: HomeAssistant) ->
fw_data=b"firmware contents",
expected_installed_firmware_type=ApplicationType.SPINEL,
bootloader_reset_methods=(),
application_probe_methods=(),
)

# Both owning integrations/addons are stopped and restarted
Expand Down Expand Up @@ -720,6 +730,7 @@ async def test_async_flash_silabs_firmware_probe_failure(hass: HomeAssistant) ->
fw_data=b"firmware contents",
expected_installed_firmware_type=ApplicationType.SPINEL,
bootloader_reset_methods=(),
application_probe_methods=(),
)

# Both owning integrations/addons are stopped and restarted
Expand Down
Loading