-
-
Notifications
You must be signed in to change notification settings - Fork 37.4k
Add repair to migrate away from multiprotocol/Multi-PAN #168431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
agners
wants to merge
18
commits into
dev
Choose a base branch
from
create-repair-to-remove-multiprotocol
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
6170156
Add repair to migrate away from multiprotocol/Multi-PAN
agners 19aecf2
Detect multi-PAN via addon state, not just firmware field
agners 523f5da
Rename repairs.py to repair_helpers.py to avoid platform discovery
agners dc4f4ad
Replace flasher addon with direct firmware flashing
agners 26df3f1
Add repairs dependency to homeassistant_hardware manifest
agners 9d96626
Update tests for direct firmware flashing flow
agners 110ba33
Merge branch 'dev' into create-repair-to-remove-multiprotocol
agners 2f1730e
Fix repair flow to render uninstall form on first invocation
agners 352e898
Update Multi-PAN repair flow translations to match new flow
agners 0a14e93
Fix `fw_install_failed` abort placeholders for Multi-PAN flow
agners b2ca7f4
Handle Supervisor errors when checking Multi-PAN add-on usage
agners e709189
Add Multi-PAN progress translations to options flow
agners 9eddc58
Apply suggestions from code review
agners 98be235
Lock the device while flashing Zigbee firmware in Multi-PAN repair flow
agners ab52d02
Initialize Multi-PAN repair flows via the explicit options-flow base
agners e1b2de2
Mock the firmware flashing context in Multi-PAN options-flow tests
agners fd04989
Catch specific firmware-flash errors in Multi-PAN repair flow
agners 90e8ed0
Use direct key access for the Multi-PAN repair issue data payload
agners File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
homeassistant/components/homeassistant_hardware/repair_helpers.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| """Repairs for the Home Assistant Hardware integration.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from homeassistant.components.repairs import RepairsFlow | ||
| from homeassistant.config_entries import ConfigEntry, ConfigFlowResult | ||
| from homeassistant.core import HomeAssistant, callback | ||
| from homeassistant.helpers import issue_registry as ir | ||
|
|
||
| ISSUE_MULTI_PAN_MIGRATION = "multi_pan_migration" | ||
|
|
||
|
|
||
| @callback | ||
| def _multi_pan_issue_id(config_entry: ConfigEntry) -> str: | ||
| """Return the issue id for the multi-PAN migration issue of an entry.""" | ||
| return f"{ISSUE_MULTI_PAN_MIGRATION}_{config_entry.entry_id}" | ||
|
|
||
|
|
||
| @callback | ||
| def async_create_multi_pan_migration_issue( | ||
| hass: HomeAssistant, | ||
| domain: str, | ||
| config_entry: ConfigEntry, | ||
| ) -> None: | ||
| """Create a repair issue to guide migration away from Multi-PAN.""" | ||
| ir.async_create_issue( | ||
| hass, | ||
| domain=domain, | ||
| issue_id=_multi_pan_issue_id(config_entry), | ||
| is_fixable=True, | ||
| is_persistent=False, | ||
| severity=ir.IssueSeverity.WARNING, | ||
| translation_key=ISSUE_MULTI_PAN_MIGRATION, | ||
| translation_placeholders={"hardware_name": config_entry.title}, | ||
| data={"entry_id": config_entry.entry_id}, | ||
| ) | ||
|
|
||
|
|
||
| @callback | ||
| def async_delete_multi_pan_migration_issue( | ||
| hass: HomeAssistant, | ||
| domain: str, | ||
| config_entry: ConfigEntry, | ||
| ) -> None: | ||
| """Delete the multi-PAN migration repair issue for this entry.""" | ||
| ir.async_delete_issue(hass, domain, _multi_pan_issue_id(config_entry)) | ||
|
|
||
|
|
||
| class MultiPanMigrationRepairFlow(RepairsFlow): | ||
| """Reuse the multi-PAN options flow uninstall steps as a repair flow. | ||
|
|
||
| Subclass this together with the hardware-specific | ||
| ``MultiPanOptionsFlowHandler`` in each hardware integration's repairs | ||
| module. | ||
|
|
||
| The repair flow runs in the repairs flow manager where ``self.handler`` | ||
| is the integration domain rather than the hardware config entry id, so | ||
| the ``config_entry`` accessor of ``OptionsFlow`` must be overridden. | ||
| """ | ||
|
|
||
| _repair_config_entry: ConfigEntry | ||
|
|
||
| @property | ||
| def config_entry(self) -> ConfigEntry: | ||
| """Return the hardware config entry to migrate.""" | ||
| return self._repair_config_entry | ||
|
|
||
| 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] | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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_addonstep as-is allows the user to submit withdisable_multi_pan=Falseand 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).