Skip to content
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

Add silabs_multiprotocol platform #92904

Merged
merged 9 commits into from Jun 1, 2023
Merged

Add silabs_multiprotocol platform #92904

merged 9 commits into from Jun 1, 2023

Conversation

emontnemery
Copy link
Contributor

@emontnemery emontnemery commented May 10, 2023

Proposed change

Add silabs_multiprotocol platform

Integrations which support using an IEEE 802.15.4 radio with multiprotocol support, currently ZHA and OTBR, can implement a silabs_multiprotocol platform which supports changing the channel.

The motivation is that the Silicon labs radio used in the Home Assistant Yellow and Home Assistant Sky Connect requires both Thread/Matter on Zigbee to be on the same channel when in multiprotocol mode.

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:
  • Link to documentation pull request:

Checklist

  • 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 Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

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 link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@home-assistant
Copy link

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 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
Copy link

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

Code owner commands

Code owners of otbr can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign otbr Removes the current integration label and assignees on the pull request, add the integration domain after the command.

@home-assistant
Copy link

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 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
Copy link

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 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
Copy link

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

Code owner commands

Code owners of thread can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign thread Removes the current integration label and assignees on the pull request, add the integration domain after the command.

@home-assistant
Copy link

Hey there @dmulcahey, @Adminiuga, @puddly, mind taking a look at this pull request as it has been labeled with an integration (zha) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of zha can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign zha Removes the current integration label and assignees on the pull request, add the integration domain after the command.

@emontnemery emontnemery marked this pull request as ready for review May 31, 2023 06:05
Copy link
Member

@agners agners left a comment

Choose a reason for hiding this comment

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

LGTM. I've tested this using the SiLabs Multiprotocol add-on. Thread and ZHA successfully migrated the channel 🎉

Copy link
Contributor

@puddly puddly left a comment

Choose a reason for hiding this comment

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

Works for me as well.

Only thing I can suggest is some UI feedback for the five minute timer, since it won't be obvious what exactly happens once the flow completes.

diff --git a/homeassistant/components/homeassistant_hardware/silabs_multiprotocol_addon.py b/homeassistant/components/homeassistant_hardware/silabs_multiprotocol_addon.py
index a11efdb8a6..055e6cace3 100644
--- a/homeassistant/components/homeassistant_hardware/silabs_multiprotocol_addon.py
+++ b/homeassistant/components/homeassistant_hardware/silabs_multiprotocol_addon.py
@@ -524,6 +524,15 @@ class OptionsFlowHandler(config_entries.OptionsFlow, ABC):
 
         # Change the shared channel
         await multipan_manager.async_change_channel(int(user_input["channel"]))
+        return await self.async_step_notify_channel_change()
+
+    async def async_step_notify_channel_change(
+        self, user_input: dict[str, Any] | None = None
+    ) -> FlowResult:
+        """Notify that the channel change will take about five minutes."""
+        if user_input is None:
+            return self.async_show_form(step_id="notify_channel_change")
+
         return self.async_create_entry(title="", data={})
 
     async def async_step_uninstall_addon(
diff --git a/homeassistant/components/homeassistant_hardware/strings.json b/homeassistant/components/homeassistant_hardware/strings.json
index 6ec352651e..2964a66c9d 100644
--- a/homeassistant/components/homeassistant_hardware/strings.json
+++ b/homeassistant/components/homeassistant_hardware/strings.json
@@ -27,6 +27,10 @@
             "channel": "Channel"
           }
         },
+        "notify_channel_change": {
+          "title": "Channel change scheduled",
+          "description": "A Zigbee and Thread channel change has been scheduled and will begin in five minutes."
+        },
         "show_revert_guide": {
           "title": "Multiprotocol support is enabled for this device",
           "description": "If you want to change to Zigbee only firmware, please complete the following manual steps:\n\n  * Remove the Silicon Labs Multiprotocol addon\n\n  * Flash the Zigbee only firmware, follow the guide at https://github.com/NabuCasa/silabs-firmware/wiki/Flash-Silicon-Labs-radio-firmware-manually.\n\n  * Reconfigure ZHA to migrate settings to the reflashed radio"

@emontnemery emontnemery merged commit 15e5cf0 into dev Jun 1, 2023
32 checks passed
@emontnemery emontnemery deleted the multipan_platform branch June 1, 2023 10:32
@balloob balloob added this to the 2023.6.0 milestone Jun 1, 2023
balloob pushed a commit that referenced this pull request Jun 1, 2023
* Add silabs_multiprotocol platform

* Add new files

* Add ZHA tests

* Prevent ZHA from creating database during tests

* Add delay parameter to async_change_channel

* Add the updated dataset to the dataset store

* Allow MultipanProtocol.async_change_channel to return a task

* Notify user about the duration of migration

* Update tests
@github-actions github-actions bot locked and limited conversation to collaborators Jun 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants