Skip to content

fix(mqtt): don't guess a DID that onboarding already paired - #166

Merged
Lash-L merged 2 commits into
mainfrom
fix/bridge-learned-did-guard
Oct 12, 2026
Merged

Lash-L merged 2 commits into
mainfrom
fix/bridge-learned-did-guard

Conversation

@Lash-L

@Lash-L Lash-L commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #165 (issue #163).

Problem

#165 made the DID/DUID pairs learned during onboarding authoritative in the topic bridge's DUID->DID map. The older unique-model fallback still runs first, though, and it can map an unpaired DUID to a DID that runtime_credentials.json already pairs with a different DUID.

Example: the inventory's only a168 isn't onboarded yet, and the only a168 DID with a known model belongs to another vacuum (for example, the one it replaced). On main the map becomes:

1mRc3mFQhMWxkAQIAGI46w -> 1103841353419   (model guess)
6aEI34L0ZtsALO8XtccuPw -> 1103841353419   (learned pair)

Commands for the unpaired vacuum are then sent to the other vacuum's topic instead of being dropped with the "no deterministic rr/d mapping" warning.

Fix

  • Collect the learned pairs before the inventory loop, and skip the model fallback for any DID they already claim. Learned pairs still override everything else, as in fix(mqtt): map same-model vacuums via learned DID/DUID pairs #165.
  • Treat an exception from runtime_credentials.devices() as "no learned pairs", the same way key_models_by_did() is handled just above it. Without this, an exception would drop the bridge's broker connection and send it through its reconnect loop.
  • Remove the --bridge-device-* hint from the two drop warnings. That option no longer exists; the warning now says to onboard the vacuum.

Testing

  • New test test_topic_bridge_model_fallback_does_not_reuse_did_learned_for_another_duid. It fails on current main and passes with this change.
  • Full suite: 335 passed.

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.
@Lash-L
Lash-L merged commit 4d068bf into main Oct 12, 2026
1 check passed
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.

1 participant