Skip to content

feat: capture and persist the full ErrorCode proto - #161

Open
kingchddg901 wants to merge 1 commit into
jeppesens:mainfrom
kingchddg901:feat/error-tracking
Open

kingchddg901 wants to merge 1 commit into
jeppesens:mainfrom
kingchddg901:feat/error-tracking

Conversation

@kingchddg901

Copy link
Copy Markdown

Summary

The novel MQTT parser decodes the ErrorCode protobuf but only ever read warn[0]. It never read the error[] array, the event timestamp, new_code, obstacle reminders, or battery-swap events — all of which arrive on the error frame and were discarded. This PR captures the whole proto and persists a rolling per-device history that survives restarts.

Motivation

On some devices (verified on an Omni/X-series unit), operational faults are reported through error[], not warn[]. Because the parser never read error[], error_message stayed permanently empty for those faults. Concretely: lifting the robot reports code 7002 ("MACHINE PICKED UP") in error[], which the current parser resolves to error_code = 0 and an empty message — so the fault is invisible.

Changes

  • Parsers — the novel parser now decodes error[], warn[], last_time, new_code.{error,warn}, battery.restored, and obstacle_reminder[] (type / photo_id / accuracy / map_id / point). The primary error_code prefers a real error[] over a warn[]. The scalar and legacy parsers mirror error_codes[] so state shape is uniform across transports.
  • StateVacuumState gains error_codes, warn_codes, last_error_time, new_error_codes, new_warn_codes, battery_restored, obstacle_reminders, and error_log. All additive with empty defaults; no breaking changes.
  • Coordinator — a per-device Store (separate from the maps store) keeps the last 50 events, newest-first, loaded on startup. "Freshness" is judged from the per-update delta, not carried-forward state, so an ongoing fault is logged once rather than every tick; a clear→fault transition is a backstop for transports without new_code.
  • Sensor — the Error Message sensor exposes the mined fields plus the full history as attributes.

Testing

Added unit tests: full-proto capture, error[]-over-warn[] priority, clear-to-empty, dedup of an ongoing fault, the legacy transition backstop, obstacle/battery logging, and the history cap. Full suite: 546 passing. pre-commit (pyupgrade / codespell / flake8 / isort / mypy / pylint) clean.

Live validation

On real hardware: lift → 7002 in error_codes[]; pulling the station tanks → 6010 / 6025 in warn_codes[]; all persisted with timestamps and resolved labels.

Notes

  • The manifest.json version is intentionally left unchanged — release_version_check runs only on release tags, so the version bump is a maintainer/release step.

The novel parser read only warn[0] and NEVER read error[] — so real device
errors, simultaneous codes, timestamps, obstacle/poop reminders, and battery
swaps all arrived and were discarded. Capture the whole proto and persist a
rolling history that survives restarts.

Parsers (all three transports):
- novel: decode error[], warn[], last_time, new_code.{error,warn},
  battery.restored, and obstacle_reminder[] (type/photo/accuracy/map/point).
  Primary error_code now prefers a real error[] over a warn[].
- scalar/legacy: mirror error_codes[] and a fresh-fault signal so state
  shape stays uniform across transports.

State (models.VacuumState): error_codes, warn_codes, last_error_time,
new_error_codes, new_warn_codes, battery_restored, obstacle_reminders,
error_log.

Coordinator: a per-device error Store (separate from the maps store, which
clobbers to one key) holds the last 50 events, newest-first, loaded on
startup. _log_error_event judges freshness from `changes` (this update's
delta), not carried-forward state fields, so an ongoing fault is logged once
rather than every update; a clear->fault transition is a legacy backstop.

Sensor: the Error Message sensor exposes error_codes, warn_codes,
last_error_time, obstacle_reminders, battery_restored, and the full history
as attributes.

Tests: full-proto capture, error[]-wins priority, clear-to-empty, dedup of
ongoing faults, legacy transition backstop, obstacle/battery logging, and
history cap.

Co-Authored-By: Claude Opus 4.8 (1M context) <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.

1 participant