Skip to content

Add repair to migrate away from multiprotocol/Multi-PAN#168431

Merged
agners merged 22 commits into
devfrom
create-repair-to-remove-multiprotocol
May 27, 2026
Merged

Add repair to migrate away from multiprotocol/Multi-PAN#168431
agners merged 22 commits into
devfrom
create-repair-to-remove-multiprotocol

Conversation

@agners
Copy link
Copy Markdown
Member

@agners agners commented Apr 17, 2026

Proposed change

The Silicon Labs Multiprotocol app (add-on) has been deprecated since July 2025 (home-assistant/addons#3833) but still has ~4400 active installations. We would like to remove the app from the repository, but simply removing it would trigger a repair that just removes the app — potentially breaking the user's currently running Zigbee/Thread setup without guidance.

This PR adds a fixable repair issue for users still running the Multiprotocol app on Home Assistant Yellow and SkyConnect. The repair hooks into the existing migration flow so users can gracefully migrate back to single-protocol (Zigbee) firmware before the app is removed.

Detection works via two signals:

  • The config entry's firmware field being cpc
  • The multiprotocol app actually running and using the device (via multi_pan_addon_using_device)

Both are checked because the firmware field can be stale/incorrect — it is only guessed once during config entry migration and is never re-evaluated. A system with the multiprotocol app running could have firmware: spinel if OTBR was installed at migration time. This was the case in my test setup, and I guess it's likely that users manually installed apps as well. This secondary check shouldn't harm anyways.

The PR also replaces the use of the Silicon Labs Flasher app during migration with direct flashing via universal-silabs-flasher (the built-in flasher already used by the Yellow/SkyConnect firmware options flow). The old approach has issues on recent Home Assistant OS installations (Yellow not correctly detected) and stale app configuration (e.g. a previously set firmware_url option causing the wrong firmware to be flashed).

The architecture (multiple inheritance mixin reusing the existing options flow steps in a repair flow context) is admittedly not the cleanest, but given that all of the multiprotocol code is deprecated and will eventually be removed, the goal here is just to get a guided migration path in front of users before we pull the app. Not worth a larger refactor for code that's on its way out.

Screenshots Yellow

image image

Screenshots ZBT-1/SkyConnect

image Screenshot From 2026-04-28 15-05-13

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue: Deprecate multiprotocol addons#3833
  • Link to documentation pull request:
  • Link to developer documentation pull request:
  • Link to frontend pull request:

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies a diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

To help with the load of incoming pull requests:

agners and others added 4 commits April 17, 2026 11:49
Create a fixable repair issue when Yellow or SkyConnect is running
multiprotocol (CPC) firmware. The repair flow reuses the existing
options flow uninstall steps to revert the radio to Zigbee-only
firmware and migrate ZHA automatically.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The firmware field in the config entry can be wrong (e.g. guessed as
"spinel" instead of "cpc") since it is only set once during migration.
Check the actual multiprotocol addon state via multi_pan_addon_using_device
in addition to the firmware field to reliably detect multi-PAN usage.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The repairs platform discovery finds any module named repairs.py and
tries to register it. Since homeassistant_hardware/repairs.py only
contains shared helpers and the mixin (no async_create_fix_flow), the
discovery fails with "Invalid repairs platform". Rename to
repair_helpers.py so it is not discovered as a platform.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use universal-silabs-flasher directly instead of the flasher addon to
flash Zigbee firmware during multi-PAN migration. This eliminates the
dependency on the flasher addon and avoids issues with stale addon
config (e.g. firmware_url being set from a previous use).

The new flow: ZHA backup via multiprotocol socket, uninstall
multiprotocol addon, download Zigbee firmware from Nabu Casa releases,
flash directly via universal-silabs-flasher, restore ZHA backup.

Also moves WaitingAddonManager from silabs_multiprotocol_addon to util
to break a circular import and allow top-level imports of
async_flash_silabs_firmware and ApplicationType.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 17, 2026 14:01
@agners agners requested a review from a team as a code owner April 17, 2026 14:01
@home-assistant
Copy link
Copy Markdown
Contributor

Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration (homeassistant_yellow) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of homeassistant_yellow can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant mark-draft Mark the pull request as draft.
  • @home-assistant ready-for-review Remove the draft status from the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign homeassistant_yellow Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant update-branch Update the pull request branch with the base branch.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) on the pull request.

@home-assistant
Copy link
Copy Markdown
Contributor

Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration (homeassistant_sky_connect) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of homeassistant_sky_connect can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant mark-draft Mark the pull request as draft.
  • @home-assistant ready-for-review Remove the draft status from the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign homeassistant_sky_connect Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant update-branch Update the pull request branch with the base branch.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) on the pull request.

@home-assistant
Copy link
Copy Markdown
Contributor

Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration (homeassistant_hardware) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of homeassistant_hardware can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant mark-draft Mark the pull request as draft.
  • @home-assistant ready-for-review Remove the draft status from the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign homeassistant_hardware Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant update-branch Update the pull request branch with the base branch.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) on the pull request.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

The repair_helpers module imports RepairsFlow from the repairs
integration.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Hedda
Copy link
Copy Markdown
Contributor

Hedda commented Apr 17, 2026

This PR adds a fixable repair issue for users still running the Multiprotocol app on Home Assistant Yellow and SkyConnect. The repair hooks into the existing migration flow so users can gracefully migrate back to single-protocol (Zigbee) firmware before the app is removed.

FYI, while not a likely some users are probably using the Multiprotocol app for Zigbee2MQTT instead of ZHA, so maybe add a note that this could in some circumstances potentially also break the user's Zigbee2MQTT setup if using this Multiprotocol app for it (as thus repair will not reconfigure Zigbee2MQTT configuration), and could also add that Zigbee2MQTT do not officially support Multiprotocol firmware https://www.zigbee2mqtt.io/guide/adapters/emberznet.html#emberznet-adapters-silicon-labs

Update all tests that referenced the old flasher addon steps to match
the new direct flashing flow (uninstall multiprotocol addon → flash
zigbee firmware → flashing complete).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
# Lazy import to avoid circular dependency
from .silabs_multiprotocol_addon import ( # noqa: PLC0415
get_multiprotocol_addon_manager,
)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using async_flash_silabs_firmware from util created a circular dependency. I've moved WaitingAddonManager to util which resolved part of it, but that one remains.

But since it is multi-protocol related, which anyways will go at one point, seems acceptable to me. Getting rid of it would need further refactoring.

Copilot AI review requested due to automatic review settings April 28, 2026 12:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 20 out of 20 changed files in this pull request and generated 4 comments.

Comment thread homeassistant/components/homeassistant_yellow/repairs.py Outdated
Comment thread homeassistant/components/homeassistant_sky_connect/repairs.py Outdated
Comment thread homeassistant/components/homeassistant_hardware/silabs_multiprotocol_addon.py Outdated
Comment thread homeassistant/components/homeassistant_sky_connect/strings.json
`super().__init__(...)` works here because Python's MRO walks past the
intervening `RepairsFlow` mixin (which has no `__init__`) and lands on
the options-flow base, but it's not obvious from reading the code —
Copilot already misread it as a TypeError. Calling the named
options-flow class directly makes intent explicit: the diamond's
options-flow side is the one that actually consumes `config_entry`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a related test failure.

Comment thread homeassistant/components/homeassistant_hardware/silabs_multiprotocol_addon.py Outdated
Comment thread homeassistant/components/homeassistant_sky_connect/repairs.py Outdated
@home-assistant
Copy link
Copy Markdown
Contributor

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@home-assistant home-assistant Bot marked this pull request as draft April 29, 2026 11:43
agners and others added 3 commits April 29, 2026 14:54
The Multi-PAN uninstall flow now wraps the Zigbee firmware flash in
`async_firmware_flashing_context`, which calls into
`homeassistant_hardware`'s firmware-update registry. The options-flow
tests don't load that integration, so the context manager raised
`KeyError('homeassistant_hardware')` and the flow ended in
`firmware_flash_failed` instead of completing. Patch the context to
no-op alongside the existing `async_flash_silabs_firmware` mock.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Previously the flow caught a bare `Exception` and logged a stack trace,
which mixes intentional flow-abort signals with unexpected programmer
errors and is noisier than other steps in this flow.

Wrap the network-side fetch (`async_update_data`, `async_fetch_firmware`,
firmware lookup) in a focused handler that converts realistic failures
(`StopIteration`, `TimeoutError`, `ClientError`, `ManifestMissing`,
`ValueError`) into `HomeAssistantError`, mirroring `firmware_config_flow`.
`async_flash_silabs_firmware` already raises `HomeAssistantError`, so
the outer handler can now catch only that and log a single line. Update
the affected tests to use the matching exception types.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`async_create_multi_pan_migration_issue` always populates the issue
data with `entry_id`, so reading it back with `dict.get` masks contract
violations rather than surfacing them. Switch to `data["entry_id"]` in
both Yellow and SkyConnect's `async_create_fix_flow`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 29, 2026 13:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.

Comment on lines +68 to +74
async def _async_step_start_migration(self) -> ConfigFlowResult:
"""Jump straight into the uninstall step of the migration flow.

The repair flow's init data is the issue context, not user form input,
so pass None to render the uninstall confirmation form.
"""
return await self.async_step_uninstall_addon() # type: ignore[attr-defined, no-any-return]
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure the repair flow cannot finish successfully unless the migration actually runs (otherwise the issue will be auto-deleted). Because RepairsFlowManager deletes the issue on any non-ABORT result, reusing the options-flow uninstall_addon step as-is allows the user to submit with disable_multi_pan=False and end the flow without fixing anything; consider overriding that step in the repair flow to abort/keep the issue open (or force a positive confirmation default).

Copilot uses AI. Check for mistakes.
Comment thread homeassistant/components/homeassistant_yellow/__init__.py Outdated
Comment thread homeassistant/components/homeassistant_sky_connect/__init__.py Outdated
@agners agners marked this pull request as ready for review April 29, 2026 14:33
@home-assistant home-assistant Bot requested a review from MartinHjelmare April 29, 2026 14:34
@MartinHjelmare
Copy link
Copy Markdown
Member

MartinHjelmare commented Apr 30, 2026

Nikita said he had some comments for this PR in progress, right? Or did I mishear that?

Edit: I mean, I think we should wait for those if that is the case.

Copilot AI review requested due to automatic review settings May 27, 2026 04:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 20 out of 20 changed files in this pull request and generated 1 comment.

"data": {
"disable_multi_pan": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::step::uninstall_addon::data::disable_multi_pan%]"
},
"description": "Multiprotocol support for the IEEE 802.15.4 radio in your {hardware_name} has been deprecated. Migrate the radio back to Zigbee-only firmware to keep it working in the future.\n\nDisabling multiprotocol support will disable Thread support provided by the {hardware_name}. Your Thread devices will continue working only if you have another Thread border router nearby.\n\nIt will take a few minutes to install the Zigbee firmware and restore a backup.",
@puddly
Copy link
Copy Markdown
Contributor

puddly commented May 27, 2026

Thanks @agners! My apologies for not getting this in last release.

I've pushed a small fix to only make this repair visible for users who are actively running multi-PAN firmware. I've also enabled the progress callback. Right now, the state of the config entry's firmware key can desynchronize heavily from what the device is actually running. For example, you can try out multi-PAN (which sets it to CPC), decide you don't like multi-PAN, use the web flasher to reinstall normal Zigbee firmware, and then set up Z2M. You would then be left with a ZBT-1 config entry that has the wrong firmware type and no way to update it. I think it would be an error if we show this repair for anybody in this state, as proceeding with the repair is impossible.

There is a bit of code duplication for flashing but this is temporary migration code that will likely be removed in a few releases (or earlier, depending on how quickly legacy users migrate!). We may also want to look into making opt-in Supervisor analytics either tag or exclude apps that are installed but not currently running, so the reported numbers are more accurate?

@MartinHjelmare MartinHjelmare added this to the 2026.6.0b0 milestone May 27, 2026
@MartinHjelmare
Copy link
Copy Markdown
Member

@agners if you're happy with Nikita's changes, go ahead and merge when ready.

@agners
Copy link
Copy Markdown
Member Author

agners commented May 27, 2026

I've pushed a small fix to only make this repair visible for users who are actively running multi-PAN firmware.

... I see, by means of checking if the Multiprotocol app is running. That makes sense, since on my end the config entry was outdated too 🙈 . If the Multiprotocol app is running and using the device, it must be Multiprotocol.

@agners agners merged commit ebd9934 into dev May 27, 2026
48 checks passed
@agners agners deleted the create-repair-to-remove-multiprotocol branch May 27, 2026 14:37
@frenck frenck removed this from the 2026.6.0b0 milestone May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants