Skip to content

Explain the printer's error codes instead of relaying numbers - #6

Open
phieb wants to merge 2 commits into
mainfrom
feature/explain-printer-errors
Open

Explain the printer's error codes instead of relaying numbers#6
phieb wants to merge 2 commits into
mainfrom
feature/explain-printer-errors

Conversation

@phieb

@phieb phieb commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Was

Bambuddy hands the bot the error number only — its hms_errors entries have no description field (code/attr/module/severity/actions/full_code), and code is just the low half of the identifier. An intervention alert therefore read:

⚠️ Fehler: 0x4003

Now it reads:

⚠️ „half height Box1 — Sticks": der Drucker meldet einen Fehler:
⚠️ 0700-2000-0002-0001 — AMS A Slot 1 Filament ist aufgebraucht. Bitte legen Sie ein neues Filament ein.
Bitte schau nach — der Druck steht.

Wie

  • hms.py resolves a code against Bambu's official catalogue — the same source Bambu Studio queries — bundled offline in hms_data/hms_{de,en}.json.gz (~4000 HMS + ~550 print_error codes per language, 65/40 kB). Bundled, not fetched: the bot must be able to explain an error while the internet is down.
  • Both namespaces the printer mixes into that one list are handled: 16-char HMS codes (0700-2000-0002-0001, encode AMS unit + slot, so the text names the real slot) and 8-char print_error codes (0702-8002). full_code is the key; when it's missing it's rebuilt from attr + code.
  • Severity picks the marker — 🛑 fatal · ⚠️ warning · ℹ️ info — from Bambuddy's field, falling back to the code's severity nibble.
  • An unlisted code still goes out as a number; that's what the wiki and support ask for.
  • scripts/refresh_hms_codes.py regenerates the tables after a firmware update.

Wo es auftaucht

vorher nachher
Eingriff-Alarm Fehler: 0x4003 Code + Klartext
!progress dito, im „ · "-Streifen eigene Zeile (ein erklärter Fehler ist ein ganzer Satz)
Fehlgeschlagen-Meldung meist gar nichts (error_message ist selten gefüllt) der stehende HMS-Code als Grund

Alert identity now keys on the full code, so two different faults in the same module no longer collapse into one incident.

Tests

225 pass (./.venv/bin/python -m pytest tests -q) — new tests/test_hms.py covers real catalogue lookups in both languages, the attr+code reconstruction, print_error codes, severity markers, unknown codes, junk-payload safety (this runs in the completion poller, where one exception kills the cycle for every tracker), plus the failure-message fallback.

🤖 Generated with Claude Code

phieb and others added 2 commits August 8, 2026 15:46
Bambuddy's `hms_errors` entries carry no description at all — the schema is
code/attr/module/severity/actions/full_code, and `code` is only the low half
of the identifier. So an alert read "⚠️ Fehler: 0x4003", which tells nobody
what to go and do.

The sentence behind a code lives in Bambu's public catalogue, the same one
Bambu Studio queries. `hms.py` looks it up against a bundled copy (both
languages, ~65/40 kB gzipped) — bundled rather than fetched so the bot can
still explain an error while the internet is down. `scripts/refresh_hms_codes.py`
regenerates it after a firmware update.

Both namespaces the printer mixes into that one list are covered: 16-char HMS
codes (which encode the AMS unit and slot, so the text names the real slot) and
8-char print_error codes. An unlisted code still goes out as a number — that's
what the wiki and support ask for. Severity picks the marker: 🛑 / ⚠️ / ℹ️.

Used by the intervention alert, !progress (on its own line — an explained error
is a full sentence and would wreck the " · " status strip) and the failure
notice, which previously said nothing at all when Bambuddy left error_message
empty, i.e. almost always.

Alert identity now keys on the full code, so two different faults in the same
module no longer collapse into one incident.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Bambu's catalogue endpoint takes `?d=<serial prefix>` — `01P` is our P1S, the
same three characters Bambuddy keys its HMS action table off. Checked what that
actually changes: nothing in the wording. Of the ~3900 codes the scoped and the
generic list share, zero differ in text; scoping only filters the set. The P1S
list omits 35 codes for hardware it doesn't have and knows 4 that the generic
list leaves out — part-cooling fan, Ethernet accessory, SD-card wear.

So fetch both and merge. Taking only the scoped list would leave rarer codes
unexplained; taking only the generic one loses the fan fault on the single
printer that can report it. A test pins the P1S-exclusive codes so a future
refresh can't quietly drop the device fetch.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@phieb

phieb commented Aug 8, 2026

Copy link
Copy Markdown
Owner Author

Nachtrag: sind die Texte P1S-spezifisch? Nachgeprüft — jein, und es hat eine Änderung nach sich gezogen.

Bambus Katalog-Endpoint nimmt ?d=<Serien-Präfix>; 01P ist unser P1S (Serial 01P00C571300842 — dieselben drei Zeichen, auf die Bambuddy seine HMS-Action-Tabelle keyt). Der Scope filtert aber nur die Menge, nicht den Wortlaut: von den ~3900 Codes, die die generische und die P1S-Liste teilen, weicht kein einziger im Text ab (in beiden Sprachen geprüft). Die P1S-Liste lässt 35 Codes für nicht vorhandene Hardware weg und kennt 4 exklusiv — Bauteilkühlung 0300-3100-…, Ethernet-Zubehör, SD-Karten-Verschleiß.

Das Skript holt jetzt beide und merged (3f8a…): nur die gescopte Liste ließe seltenere Codes unerklärt, nur die generische verlöre ausgerechnet den Lüfterfehler auf dem einzigen Drucker, der ihn melden kann. Ein Test pinnt die vier P1S-Codes, damit ein späterer Refresh den Device-Fetch nicht still fallen lässt. 226 Tests grün.

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