Allow external radio types#461
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #461 +/- ##
=======================================
Coverage 97.41% 97.42%
=======================================
Files 50 50
Lines 10419 10433 +14
=======================================
+ Hits 10150 10164 +14
Misses 269 269 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
I've slightly expanded the scope of this PR to clean up and entirely remove the |
|
Thanks @puddly for working on this — external radio type support would be a big deal for zigpy-blz. We currently maintain a custom ZHA component to patch BLZ radio support into ZHA, which requires tracking every HA Core release. This PR would let us drop that entirely and ship as a standalone We tested this PR locally with a Third Reality BL702 dongle — the Gateway successfully resolves and connects to zigpy-blz through |
0a08169 to
a286998
Compare
a286998 to
56ea7d5
Compare
There was a problem hiding this comment.
Pull request overview
This PR refactors ZHA’s radio selection to support externally provided zigpy radio libraries (discovered via Python entry points), enabling experimentation with pre-alpha radio backends without hard-coding them into ZHA.
Changes:
- Introduces a
RadioLibraryregistry with entry-point discovery (zigpy.radio) alongside built-in radios. - Updates
Gatewayinitialization to resolve/import the selected radio controller dynamically (off the event loop). - Removes the hard-coded
RadioTypeenum and updates tests/fixtures accordingly.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
zha/zigbee/device.py |
Uses the selected radio library’s display name when coordinator model is unknown. |
zha/application/helpers.py |
Adds RadioLibrary + external radio discovery via entry points. |
zha/application/gateway.py |
Switches radio selection from enum to dynamic registry and imports controller in executor. |
zha/application/const.py |
Removes the hard-coded RadioType enum and related imports. |
tests/test_gateway.py |
Updates gateway tests and adds coverage for external radio discovery/behavior. |
tests/conftest.py |
Adjusts gateway test harness mocking to align with dynamic controller resolution. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| # The actual controller class will be imported dynamically | ||
| controller: type[ControllerApplication] = None # type: ignore[assignment] | ||
|
|
| def get_radio_libraries() -> dict[str, RadioLibrary]: | ||
| """Return built-in and discovered external radio libraries, keyed by radio type.""" | ||
|
|
||
| radio_libraries: dict[str, RadioLibrary] = dict(RADIO_LIBRARIES) | ||
|
|
| def get_application_controller_config(self) -> dict: | ||
| """Get an uninitialized instance of a zigpy `ControllerApplication`.""" | ||
| app_config = self.config.zigpy_config |
|
Any status updates on this support to allow external radios? For reference also see this related PR for zigpy -> zigpy/zigpy#1836 |
|
@Hedda I appreciate your enthusiasm but as you can see, this PR was updated just a few days ago. If there's any update, it will be here. |
This will need a corresponding PR to Core (https://github.com/puddly/core/tree/puddly/zha-external-radio-libs) but will allow for pre-alpha radio libraries (Ziggurat, ZBOSS, BLZ, and ESPZB) to be used in Home Assistant.
You first need to modify your radio library's
pyproject.tomlfile to register it with zigpy:And then just add a description to the
ControllerApplicationsubclass:Unfortunately, HA Core provides no simple way to install custom dependencies other than a custom component. I'll make a custom component later (if one doesn't already exist) so you can add something like this to
configuration.yaml:That's it. The Python module will self-register and show up in ZHA config flows, etc.
This is fundamentally a development tool so expect breakage if you rely on it 😄.