Skip to content

fix(mqtt): map same-model vacuums via learned DID/DUID pairs - #165

Merged
Lash-L merged 1 commit into
Python-roborock:mainfrom
AndLindemann:fix/topic-bridge-learned-did-map
Oct 12, 2026
Merged

Lash-L merged 1 commit into
Python-roborock:mainfrom
AndLindemann:fix/topic-bridge-learned-did-map

Conversation

@AndLindemann

Copy link
Copy Markdown
Contributor

Fixes #163

Problem

When two or more vacuums of the same model are onboarded, the MQTT topic bridge cannot map any of them. _refresh_duid_to_did_map only uses:

  • an explicit did in the cloud inventory. Cloud imports normally do not include it.
  • a fallback that needs exactly one vacuum of a given model.

With same-model vacuums, neither applies. The bridge then drops traffic in both directions:

MQTT topic bridge dropped rr/m/i/.../ej7PNYHNhbpcFJZd8HMoZ: no deterministic rr/d mapping for duid=ej7PNYHNhbpcFJZd8HMoZ (seen rr/d devices=3).

The server already knows the correct pairs. It stores them in runtime_credentials.json during onboarding (learned onboarding MQTT credentials did=... duid=...).

Fix

  • Seed the DUID->DID map from runtime_state.runtime_credentials.devices(). These learned pairs override the inventory heuristics.
  • Remove the early return on an empty inventory, so learned pairs still apply. When neither source has pairs, behaviour is the same as before.

Testing

  • New regression test in tests/test_topic_bridge.py: three roborock.vacuum.a10 devices with no did in the inventory. Each DUID must resolve to its own device topic. The test fails before the fix and passes after it.
  • Full suite: 334 passed.
  • Verified on a live setup with 3x S6 MaxV (roborock.vacuum.a10). After the patch, the map contains all three pairs, m->d / d->m traffic flows for each vacuum, and Home Assistant detects all three, including maps.

🤖 Generated with Claude Code

The topic bridge built its DUID->DID map only from an explicit `did` in
the cloud inventory (normally absent) or a unique-model fallback. With
two or more vacuums of the same model, neither applied, so every request
was dropped with "no deterministic rr/d mapping".

Seed the map from the DID/DUID pairs the server already learns during
onboarding (runtime_credentials.json). Also drop the early return on an
empty inventory so learned pairs still apply.

Fixes Python-roborock#163

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Lash-L

Lash-L commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Thank you! Have some tweaks, but i'm going to merge in and then modify.

@Lash-L
Lash-L merged commit 5b88453 into Python-roborock:main Oct 12, 2026
3 checks passed
Lash-L added a commit that referenced this pull request Oct 12, 2026
* fix(mqtt): don't guess a DID that onboarding already paired

Follow-up to #165. The unique-model fallback could still map an unpaired
DUID to a DID that runtime_credentials.json pairs with a different DUID
(e.g. a replaced vacuum), so two DUIDs routed to one vacuum. Collect the
learned pairs before the inventory loop and skip the fallback for DIDs
they already claim.

Also tolerate runtime_credentials.devices() raising, matching
key_models_by_did(), and drop the --bridge-device-* hint from the drop
warnings; that option no longer exists.

* fix(mqtt): harden runtime credentials devices iteration and add tests
arjansingh added a commit to arjansingh/local_roborock_server that referenced this pull request Oct 18, 2026
The rule said upstream uses sentence-case subjects with no type prefix.
Upstream changed in 2026-09: in October 2026, 10 of 14 subjects were
type(scope): summary, e.g. fix(mqtt): ... (Python-roborock#165). Following the old rule
would make every contribution look out of date.

Describe the current form, the types and scopes upstream uses, and tell the
reader to re-check git log upstream/main before relying on it.

Co-Authored-By: Claude <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.

Topic bridge drops all traffic for multiple vacuums of the same model ("no deterministic rr/d mapping")

2 participants