Fall back to the default TX power when a restored backup's TX power is rejected - #755
zigpy-review-bot wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #755 +/- ##
==========================================
+ Coverage 99.55% 99.58% +0.02%
==========================================
Files 64 64
Lines 4284 4294 +10
==========================================
+ Hits 4265 4276 +11
+ Misses 19 18 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Ok there's a first try to test the new code. The attached log is from the restore process: home-assistant_zha_2026-09-20T11-53-37.201Z.log The whole process went well. I did a lot of testing with the current version at the time, and I think that this test also produced an error. When I have a little more time, I'll perform a full test of migrating from the "Home Assistant Connect ZBT-2" to the BV 2010/10 ZHA dongle. |
|
I have checked the full migration process succesfully with the new code. Previous to the test I have migrated from my current zigbee dongle (BV 2010/10) to the 'Home Assistant Connect ZBT-2'. Once migrated I have restarted my HA instance. After the restart, I have enbled the ZHA debug logs and I migrated from the 'Home Assistant Connect ZBT-2' to my BV 2010/10 dongle. This time, the migration process finish succesfully and my zigbee network is available. This is the migration debug file: Let me know if you need me to do any other kind of tests. |
puddly
left a comment
There was a problem hiding this comment.
If it works then this looks good to me!
|
And as a note for my future self, I was able to test against the branch following the instructions in this post: configuring against the branch: pypi:
- >-
git+https://github.com/zigpy/bellows@zigpy-bot/restore-invalid-tx-power-fallback
apk: [] |
Fixes the network restore failure reported in home-assistant/core#176927.
Problem
Migrating a network from a Home Assistant Connect ZBT-2 to an old EM357-based adapter fails while restoring the backup:
formNetworkreturnsEmberStatus.PHY_INVALID_POWERandwrite_network_inforaisesFormationFailure, leaving the config flow stuck on "Restoring network settings to new adapter".Since #690,
write_network_infoforms the network with the TX power stored in the backup instead of the previously hard-coded 8 dBm. That value comes from whatever radio created the backup: the ZBT-2 firmware recommends 10 dBm for EU/CEPT countries, so a backup taken from it containstx_power: 10. The EM35x tops out at 8 dBm and appears to reject anything higher outright, where newer radios clamp it.Fix
write_network_inforetriesformNetworkonce withDEFAULT_TX_POWER(8 dBm, the value every restore used before Backup/restore routing table and allow specifying TX power during formation #690) when the radio rejects the backup's TX power. zigpy re-applies the configured or recommended TX power on startup anyway (whenever a TX power or country is configured; ZHA passes Home Assistant's country along), so the value used during formation only needs to be one the radio accepts.EZSP.formNetworkraises a newInvalidTxPowerexception for this status. It subclassesFormationFailure, so existing handlers are unaffected.EmberStatus.PHY_INVALID_POWERis now mapped tosl_Status.TRANSMIT_INVALID_POWER(likePHY_INVALID_CHANNEL→TRANSMIT_INVALID_CHANNELright next to it), which also gets rid of theUnknown status <EmberStatus.PHY_INVALID_POWER: 139>warning from the issue.Testing
Unit tests only, I don't have an EM35x adapter to try this on. The backup from the issue isn't attached, so the 10 dBm value is inferred from the ZBT-2 firmware's country table rather than read from it.
@javicalle, if you still have that setup around, could you check whether the migration to the Bitron stick goes through with this branch? A debug log of the restore would confirm the TX power that ends up in the backup.
cc @TheJulianJES