Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #294 +/- ##
=======================================
Coverage 98.57% 98.58%
=======================================
Files 43 43
Lines 3582 3602 +20
=======================================
+ Hits 3531 3551 +20
Misses 51 51 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟡 Changes recommended
Callback cancellation can release the request lock without confirmed recovery or connection-failure notification, exposing queued requests to a potentially stuck parser, while tests do not verify recovery from an incomplete frame.
2 open issues
What changed in this PR
This PR adds runtime recovery for Z-Stack UART frame corruption, aiming to restore communication after a missing synchronous response without restarting.
Changes:
- Flush the UART parser and probe the radio after a response timeout, notifying connection loss if recovery fails.
- Reduce the default synchronous-response timeout to 3 seconds while retaining longer network-start deadlines.
- Add tests for recovery traffic, failed recovery, and request serialization.
| File | Description |
|---|---|
zigpy_znp/config.py |
Reduce the default synchronous-response timeout. |
zigpy_znp/api.py |
Add UART recovery and separate synchronous-response timeout control. |
tests/api/test_request.py |
Test recovery outcomes and blocking of queued requests during recovery. |
Review effort: Balanced
| ): | ||
| # We lock until either a sync response is seen or an error occurs | ||
| response = await response_future | ||
| except TimeoutError: |
| """ | ||
|
|
||
| LOGGER.debug("Flooding radio UART to reset the MT frame parser") | ||
| self._uart.write(b"\x01" + b"\x00" * 257) |
|
Is there a way for me to patch HA’s zigpy install to include this PR? My system is “production” so I’d really prefer not to have to dismantle my Zigbee network to test |
|
There should be a way. I'm not sure if it has changed recently though or if the current addon to do so is still valid. @zigpy-review-bot Is https://github.com/home-assistant/apps-development/blob/master/custom_deps/ still valid? If so, provide instructions to test this PR. |
This comment was marked as outdated.
This comment was marked as outdated.
|
@zigpy-review-bot Double check that the deps directory is still loaded with latest versions of HA, I think there was a change. If so, maybe push custom integration replacing built-in ZHA to some GitHub repo/branch that can be downloaded as a ZIP and installed. Give instructions if so. |
|
You were right, and my earlier answer was wrong for current Home Assistant. Home Assistant Core removed support for What I did insteadI pushed a custom integration that replaces the built-in ZHA, on the branch Instructions (Home Assistant 2026.11.x)
Caveats
|
|
@zigpy-review-bot - thanks for the firmware build! Worked fine for me. |
|
Did |
|
@puddly quite a few times in one OTA update. |
|
That's one crash every few minutes, sometimes multiple in a row in the same minute... Can you attach the debug log for the transfer? Maybe the adjustment to the SRSP timeout is too tight and these are delayed responses, not necessarily lost. |
|
@puddly just based on my personal experience, once it times out, it’s done for. So if it works, I’d be hesitant to wait much longer. Your call, of course. Here’s one of those log snippets (I can attach the full log, but I have around 200K log lines from it…) |
|
Thanks! It looks like these are all 50 byte OTA responses. I wonder if your radio just crashes if packets are too big? We limit the packet size to 50 bytes (https://github.com/zigpy/zigpy/blob/64b51efe715b221db4edf05e8a0e176f1782a146/zigpy/ota/manager.py#L47) but this was changed back in 2026.4.0, it was 40 before. |
|
@puddly I do have some logs from the ESPHome firmware from when I first started investigating. I hope this is the correct one. This is the normal ESPHome stream server, on vanilla ZHA, with no mechanism for recovery. interestingly, data updates from the radio keep on coming from other devices even during an OTA timeout I also have logs from an ESPHome automatic recovery too if it would help. I really don’t know what further things you guys can do for a TI issue, but I want to help make this as robust as possible in the face of incompetent Z-Stack devs 🤣 |


There's a persistent firmware bug with TI's Z-Stack that causes bytes to be lost in the firmware. Since frames can never time out, the firmware just sits there waiting for more bytes indefinitely. We can try to recover from this situation by sending
b"\x01" + b"\x00" * 257if a SRSP never arrives in time.I've tightened timing for commands based on timings from user logs. Our existing SRSP timeout was really high compared to what real users see. Combined with the re-sync hack above, this should theoretically allow zigpy-znp to recover at runtime, without requiring a restart.
@inventor7777 @jmdetrez please try this PR out and let me know if it helps. Thanks!