Repository navigation
Keep each robot's last-known state and serve it at /user/devices/{duid}/last_known - #251
Open
virtitnerd wants to merge 7 commits into
Open
virtitnerd wants to merge 7 commits into
virtitnerd wants to merge 7 commits into
Conversation
This was referenced Nov 13, 2026
virtitnerd
force-pushed
the
pr/last-known-state
branch
from
November 14, 2026 15:00
6db4fff to
83a5b09
Compare
The last status, battery and error a robot sent, its last position and the map it was on, and when it last spoke or went offline, written under device_snapshots/ so it survives a restart. A robot that dies or loses Wi-Fi stops answering; this is what is left to say where it was. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Robot-originated frames update the store: status pushes (dps 120/121/122), get_status answers, and the map reply, which is decrypted with the nonce of whichever client's request asked for it. A closing robot connection marks the device offline at once. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Returns status, position, last_seen_at and offline_at; ?map=1 adds the last map the robot sent so a client can draw it while the robot cannot be asked. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A robot that went quiet before the store existed still has its last status, battery and map in the decoded MQTT log. On startup, in a background thread, devices the store has no snapshot for are filled in from that log: last time heard, last status, and the last map decoded with the nonce of the request that asked for it. Devices that already have a snapshot are left alone. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…h it The snapshot had the last map but not which segment is which room, so an offline map could only show generic labels. The proxy now records each get_room_mapping answer, the startup seed reads it from the MQTT log, and /last_known adds each room's name from the home data. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both calls return the same status object, so either one now updates the stored state. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
virtitnerd
force-pushed
the
pr/last-known-state
branch
from
November 15, 2026 21:43
83a5b09 to
17936cd
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.
Why
A robot that loses Wi-Fi, gets stuck or is switched off stops answering, and from then on nothing says where it
was or what it last reported. A client has no way to show anything for it, and no way to tell "never paired" from
"paired but offline right now".
What
The server keeps, per robot and across restarts: when it last spoke and when its connection last closed, the last
status it sent (state, battery, error), its last position and the map it was drawn on, and its room table with the
room names from the home data. It is fed from the MQTT proxy (status pushes, the answers to
get_statusandget_room_mapping, and the decryptedget_map_v1reply) and seeded from the existing MQTT log on startup.GET /user/devices/{duid}/last_knownreturns it.data.knownisfalsefor a robot the server has never heardfrom.
?map=1adds the last map.Testing
New tests cover the store, the route and the room table. Full suite: 480 passed. I also used it daily against a
Qrevo Pro and a Qrevo Curv 2 Flow.
Notes
docs/last_known_state.md.