Repository navigation
Conversation
infy1995
force-pushed
the
fix/mqtt-device-health
branch
from
November 14, 2026 09:56
bab8eb2 to
604ad59
Compare
infy1995
added a commit
to infy1995/python-roborock
that referenced
this pull request
Nov 21, 2026
The broker can stop delivering one device's messages while the shared session keeps working for the others. The health manager counted timeouts for the whole session and any successful response reset the count, so a working device hid a failing one and the session was never restarted (Python-roborock#1012). Subscribing to the topic again on the same connection does not help; only a new connection does. Also count consecutive timeouts per device, reset only by that device's own response, and restart the session after 3 of them. Timeouts from several devices in a row still restart the session at once. A restart can't fix a device that is offline, so after a device restarts the session it may do so again only after 1 hour, then 2 and 4 hours, and at most every 6 hours, until it responds again. While it waits, its timeouts don't count towards the session either, so a stray timeout of another device doesn't bypass that interval.
A restart requested by the health manager disconnects a session whose broker was reachable, so waiting for the backoff interval only kept every device on the session without MQTT for ten seconds. Reconnect at once after a restart of a connected session; connections lost for any other reason, a restart while still connecting, and a failed first reconnect attempt still wait for the backoff. Every new connection also clears the timeouts counted on the previous one, and the session tells the health manager whether it is connected so that timeouts during a reconnect don't trigger a restart.
The health management section described local connection recovery as the HealthManager and stated that A01/B01 devices don't need one. Split it into local connection recovery and MQTT health management, covering the restart conditions and their pacing.
infy1995
added a commit
to infy1995/python-roborock
that referenced
this pull request
Nov 29, 2026
infy1995
added a commit
to infy1995/python-roborock
that referenced
this pull request
Nov 29, 2026
infy1995
force-pushed
the
fix/mqtt-device-health
branch
from
November 29, 2026 09:34
604ad59 to
2ae567c
Compare
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #1012.
Problem
All devices on an account share one MQTT session. On my account, the broker sometimes stops delivering a Saros 10R's (V1,
roborock.vacuum.a144) MQTT responses, while an F25 Ultra (A01,roborock.wdv.a194) on the same connection keeps working. TheHealthManagercounted timeouts for the whole session, and any successful response reset that count. The F25's responses hid the Saros's timeouts, so the session was never restarted. In Home Assistant the map is only available over MQTT, so it stopped updating for hours. Status, battery and commands kept working because they use the local connection.The debug log in #1012 shows it with the official release: the connection stays up (PINGREQ/PINGRESP every 45 s), the F25 got 61 of 61 replies, while 91
GET_MULTI_MAPS_LISTrequests to the Saros timed out in a row. Reloading the integration opened a new connection and the Saros answered right away.Changes
HealthManager.on_success()/on_timeout()now take adevice_id, andMqttChannel.health_managerreturns aDeviceHealthManager, whose no-argument methods match the old usage.CONNECT, so if that attempt fails, including withRC_ERROR_UNAUTHORIZED, the normal backoff applies. A test covers that.docs/DEVICES.mddescribed local connection recovery as theHealthManager. It said A01/B01 devices don't need one. I split it into local connection recovery and MQTT health management.Size: 9 files, +626/−73. About two thirds of those lines are tests.
Testing
pre-commit run --all-files: ruff, mypy, codespell and the other hooks pass. Unit tests: 3297 passed. MQTT broker tests (-m mqtt_broker) against EMQX fromcompose.yaml: 11 passed.What we observed
These are observations from one account, not an explanation.
We can't tell whether the broker stops forwarding our requests to the device or the device's replies to us. Requests are QoS 0, so nothing confirms delivery.
Results with the earlier version of this branch
These came from the previous version, which counted timeouts within a 30-minute window. The restart itself and the immediate reconnect are unchanged.
What didn't work, or was dropped
GET_NETWORK_INFOevery 10 minutes). It found broken topics while the vacuum was idle, but that meant a restart every 3–4 hours that nobody needed. Without it, a broken topic is found by the next map requests.Considered and not done
Follow-ups
mqtt_healthdiagnostics per device (failing since, last success and timeout, recent restarts), in a separate PR after this one.