Skip to content

fix(mqtt): only mark a vacuum online from its own MQTT traffic - #312

Merged
Lash-L merged 1 commit into
mainfrom
fix/online-from-robot-traffic
Nov 29, 2026
Merged

Lash-L merged 1 commit into
mainfrom
fix/online-from-robot-traffic

Conversation

@Lash-L

@Lash-L Lash-L commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Offline vacuums were reported as online: true in home data (/v2, /v3, /v4/user/homes/...), /user/devices/{duid} and the device list.

RuntimeState.record_mqtt_message marked a vacuum connected on any MQTT message whose topic named it. That includes the requests the app and Home Assistant publish on rr/m/i/<u>/<mqtt_usr>/<duid>, which they send whether or not the vacuum is there. Each request set connected=True and tied the vacuum to the client's connection, so an offline vacuum read online for as long as Home Assistant kept its MQTT session open. In the app, the device list then offers start/pause/dock on a vacuum that can't receive them instead of showing it offline.

Now:

  • Only the vacuum's own publishes (c2b on rr/d/i/<did>/...) mark it connected. App/HA traffic is still logged and still feeds pairing events.
  • New RuntimeState.record_device_mqtt_login, called from the proxy when a vacuum authenticates with its own MQTT credentials, marks it connected right away, before its first publish.
  • The existing 180 s grace before a disconnected vacuum reads offline is unchanged.

Not an rc1 regression; this has been the behaviour since the first commit.

Proof that it works

Tested on:

  • Vacuum model: Qrevo MaxV 2 (a87), online; a Q7 and an S7 on the same account, both offline
  • Firmware version: a87 02.34.04
  • Server version / commit: v1.3.0-rc1 + this change (branch rebased on current main)
  • Install method: Home Assistant add-on (local build)

What I did and what happened:

  • Unpatched rc1: home data reported the offline Q7 online: true (Home Assistant had polled it on its open MQTT session), S7 false, a87 true.
  • Patched build: after the restart all three read false until the a87 logged in; it read true about 8 s later.
  • Published a read-only get_status on the Q7's and S7's app→robot topics (the server logged both PUBLISHes) and read home data before, during (session held open 20 s) and after: Q7 and S7 stayed false, the a87 stayed true. No errors in the server log.
  • tests/test_home_data_online.py: two new cases reproduce an app-polled offline vacuum reading online on the old code and pass with the fix. test_admin_api.py::test_ui_api_health_and_vacuums_require_admin_auth relied on app traffic marking a vacuum connected and now publishes on the vacuum's own topic.
  • Full suite: 880 passed.

Not tested live: a vacuum that really drops off (it still reads online for up to the 180 s grace).

Screenshots (required for any UI change)

No UI changes.

🤖 Generated with Claude Code

record_mqtt_message marked a vacuum connected on any message whose topic
named it, including app and Home Assistant requests on rr/m/i/.../<duid>.
An offline vacuum that a client polls then reported online until that
client's MQTT connection closed.

Only the vacuum's own c2b publishes on rr/d/i/<did>/... now mark it
connected, and the proxy marks it connected as soon as it logs in with
its own MQTT credentials.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 29, 2026 18:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@Lash-L
Lash-L merged commit d09fb0f into main Nov 29, 2026
1 check passed
Lash-L added a commit that referenced this pull request Nov 29, 2026
Bump the package to 1.3.0-rc2 and point the opt-in Beta add-on at it.
The v1.3.0-rc1 release build failed on a flaky test (fixed in #308), so
no rc1 image was published; rc2 replaces it and adds #312, #313 and
#314. The stable add-on stays on 1.2.1.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants