Repository navigation
Conversation
Two bugs that compound, so no filament is deducted for a print started from the printer itself rather than from Bambu Studio. 1. The tracker dispatch is gated on print_type == "local", but print_type is read when the project_file command arrives, and the printer still reports "idle" there -- it flips to "local" one MQTT message later. So apply_ams_mapping() never ran for a local print. 2. The local path then hardcodes ams_mapping = [] on a later message, clobbering the mapping from the project_file payload. Either one leaves using_ams False, so every layer is attributed to the external spool (trayUid ending _255_254), which has no spool assigned and deducts nothing. apply_ams_mapping() already no-ops on an empty mapping, so calling both unconditionally is safe for cloud prints too, and the printer's own mapping is still in PRINTER_STATE, so reuse it instead of clearing it.
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.
May be relevant to #84, #91 and #90 — I haven't read those threads closely,
so treat that as a guess rather than a claim.
Problem — two bugs that compound
1. The dispatch is gated on a
print_typethat isn't set yet (:391-397).print_typeis copied fromPRINTER_STATEat:260, at the moment theproject_filecommand arrives — but the printer still reports"idle"there andonly flips to
"local"one MQTT message later. So for a local print the"local"branch never runs andapply_ams_mapping()is never called.2. The local path then hardcodes an empty mapping (
:318).This runs on a later message and clobbers whatever mapping was established from
the
project_filepayload.Net effect:
using_amsgoesFalseand every layer's usage is attributed to theexternal spool (
trayUidending_255_254), which has no spool assigned, sonothing is deducted in Spoolman. The log line is
Queued <mm> for filament 0 (tray <serial>_255_254 has no assigned spool).Cloud prints go down a different branch, which is why this isn't visible from
Bambu Studio.
Fix
Call both unconditionally —
apply_ams_mapping()already no-ops on an emptymapping, so it's safe either way — and reuse the printer's own mapping (which
persists in
PRINTER_STATE["print"], merged from theproject_filepayload)instead of clearing it.
Debugging notes for reviewers
The two bugs look identical in the logs. Grep for
Applying AMS mapping: absentmeans bug 1; present but usage still landing on
..._255_254means bug 2.Also worth knowing: duplicated
Parsed N gcode operationslines are normal here,not two processes — tracking legitimately starts from two code paths.
Testing
Running in production on a LAN-mode P1S (AMS via a BMCU, 4 slots) since 2026-08,
rebased onto
mainand redeployed mid-print on 2026-09-03. Per-layer deductionsland on the correct spools across filament changes — the log goes from
to
i.e. real tray UIDs instead of the
_255_254external-spool fallback, with theweights reflected in Spoolman afterwards.
Caveat on scope: I can only test the local/LAN path. The cloud path now also
calls
apply_ams_mapping()where it previously didn't — that call no-ops on anempty mapping, but a cloud-print sanity check from someone set up for it would be
worth having before merge.