mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-05-09 05:35:30 +02:00
[GH-ISSUE #957] [Bug]: not correct filament usage when 2 spools are used (end of the first one) #665
Labels
No labels
A1
automated
automated
bug
bug
Closed due to inactivity
contrib
dependencies
dependencies
duplicate
enhancement
feedback
hold
invalid
Notes
P1S
pull-request
security
security
ThumbsUp
user-report
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/bambuddy#665
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @platini76 on GitHub (Apr 12, 2026).
Original GitHub issue: https://github.com/maziggy/bambuddy/issues/957
Originally assigned to: @maziggy on GitHub.
Bug Description
I made a print when a spool was near to the end and I see that all usage was subtracted from the second.
I also want to suggest a page where possible to see and manage spool usages
Expected Behavior
I espect that every spool will be used as real
Steps to Reproduce
print was send from bambu studio mac
Printer Model
H2C
Bambuddy Version
v0.2.3b3
Printer Firmware Version
01.01.05.00
Installation Method
Manual (git clone)
Operating System
Linux (Ubuntu/Debian)
Relevant Logs / Support Package
No response
Screenshots
No response
Additional Context
No response
Checklist
@maziggy commented on GitHub (Apr 13, 2026):
Please upload a support package -> https://wiki.bambuddy.cool/features/system-info/?h=debug#enable-debug-logging
@enjoylifenow commented on GitHub (Apr 14, 2026):
I think I have a similar problem. I have printed an object in Bambu Basic PLA black on my P2S.
config:
a) SPOOL 1: /api/v1/inventory/spools/1
{
"material": "PLA",
"subtype": "Basic",
"color_name": "Black",
"rgba": "000000FF",
"brand": "Bambu Lab",
"label_weight": 1000,
"core_weight": 216,
"core_weight_catalog_id": null,
"weight_used": 1271.82,
"slicer_filament": "GFA00",
"slicer_filament_name": "Bambu PLA Basic",
"nozzle_temp_min": 190,
"nozzle_temp_max": 230,
"note": null,
"tag_uid": "E6463FE200000100",
"tray_uuid": "79D00835DAB34E70A290F6C0793666C2",
"data_origin": "rfid_auto",
"tag_type": "bambulab",
"cost_per_kg": 13.22,
"weight_locked": false,
"last_scale_weight": null,
"last_weighed_at": null,
"id": 1,
"added_full": null,
"last_used": "2026-04-14T05:06:43.585696",
"encode_time": null,
"archived_at": null,
"created_at": "2026-04-11T16:41:16",
"updated_at": "2026-04-14T05:06:43",
"k_profiles": []
}
a) SPOOL 2: /api/v1/inventory/spools/7
{
"material": "PLA",
"subtype": "Basic",
"color_name": "Black",
"rgba": "000000FF",
"brand": "Bambu Lab",
"label_weight": 1000,
"core_weight": 216,
"core_weight_catalog_id": null,
"weight_used": 150,
"slicer_filament": "GFA00",
"slicer_filament_name": "Bambu PLA Basic",
"nozzle_temp_min": 190,
"nozzle_temp_max": 230,
"note": null,
"tag_uid": "267534E200000100",
"tray_uuid": "CE52B1B696D547DA8240483B33C9519D",
"data_origin": "rfid_auto",
"tag_type": "bambulab",
"cost_per_kg": 13.22,
"weight_locked": false,
"last_scale_weight": null,
"last_weighed_at": null,
"id": 7,
"added_full": null,
"last_used": "2026-04-14T05:06:43.590270",
"encode_time": null,
"archived_at": null,
"created_at": "2026-04-13T20:09:09",
"updated_at": "2026-04-14T05:06:43",
"k_profiles": []
}
Debugging was unfortunately not active when the problem did occur. I have however found some logging in the docker compose log:
bambuddy | 2026-04-14 07:06:43,564 WARNING [backend.app.services.bambu_ftp] Failed to delete /A320_Rudder_Pedal_Mod_for_Logitech_Saitek.gcode: 550 Delete operation failed.
bambuddy | 2026-04-14 07:06:43,568 WARNING [backend.app.main] SD card cleanup failed after 3 attempts for /A320_Rudder_Pedal_Mod_for_Logitech_Saitek.gcode (file may linger on SD card)
bambuddy | 2026-04-14 07:06:43,568 INFO [backend.app.main] [TIMING] SD card cleanup: 12.557s elapsed
bambuddy | 2026-04-14 07:06:43,571 INFO [backend.app.main] [TIMING] Queue item update: 12.561s elapsed
bambuddy | 2026-04-14 07:06:43,577 INFO [backend.app.services.usage_tracker] [UsageTracker] on_print_complete: printer=1, archive=13, session=yes, ams_mapping=[-1, -1, -1, 0, -1]
bambuddy | 2026-04-14 07:06:43,578 INFO [backend.app.services.usage_tracker] [UsageTracker] PRINT COMPLETE printer 1: mapping=[65535, 65535, 65535, 3], tray_now=255, last_loaded_tray=3
bambuddy | 2026-04-14 07:06:43,583 INFO [backend.app.services.usage_tracker] [UsageTracker] 3MF: archive 13, filament_usage=[{'slot_id': 4, 'used_g': 321.2, 'type': 'PLA', 'color': '#000000'}]
bambuddy | 2026-04-14 07:06:43,583 INFO [backend.app.services.usage_tracker] [UsageTracker] 3MF: slot_to_tray=[-1, -1, -1, 0, -1] (source: print_cmd)
bambuddy | 2026-04-14 07:06:43,583 INFO [backend.app.services.usage_tracker] [UsageTracker] 3MF: slot_id=4 -> global_tray=0 -> AMS0-T0 (used_g=321.2, tray_now_override=None)
bambuddy | 2026-04-14 07:06:43,585 INFO [backend.app.services.usage_tracker] [UsageTracker] Spool 1 consumed 321.2g (3MF, print_cmd_map) on printer 1 AMS0-T0 (completed)
bambuddy | 2026-04-14 07:06:43,590 INFO [backend.app.services.usage_tracker] [UsageTracker] Spool 7 consumed 150.0g (15%) on printer 1 AMS0-T3 (AMS fallback, completed)
bambuddy | 2026-04-14 07:06:43,595 INFO [backend.app.main] [TIMING] Usage tracker: 12.584s elapsed
bambuddy | 2026-04-14 07:06:43,597 INFO [backend.app.services.spoolman_tracking] [SPOOLMAN] No tracking data for print (printer=1, archive=13)
bambuddy | 2026-04-14 07:06:43,598 INFO [backend.app.main] [TIMING] Spoolman usage report: 12.587s elapsed
bambuddy | 2026-04-14 07:06:43,598 INFO [backend.app.main] [TIMING] Filament usage tracking: 12.587s elapsed
bambuddy | 2026-04-14 07:06:43,598 INFO [backend.app.main] [TIMING] Archive lookup: 12.587s elapsed
bambuddy | 2026-04-14 07:06:43,598 INFO [backend.app.main] [ARCHIVE] Updating archive 13 status...
bambuddy | 2026-04-14 07:06:43,603 INFO [backend.app.main] [ARCHIVE] Archive 13 status updated to completed, failure_reason=None
bambuddy | 2026-04-14 07:06:43,604 INFO [backend.app.main] [ARCHIVE] WebSocket notification sent for archive 13
bambuddy | 2026-04-14 07:06:43,604 INFO [backend.app.main] [TIMING] Archive status update: 12.593s elapsed
bambuddy | 2026-04-14 07:06:43,610 INFO [backend.app.main] [PRINT_LOG] Log entry written for archive 13
bambuddy | 2026-04-14 07:06:43,610 INFO [backend.app.main] [TIMING] Print log entry: 12.600s elapsed
bambuddy | 2026-04-14 07:06:43,610 INFO [backend.app.main] [TIMING] Background tasks scheduled (energy, photo): 12.600s elapsed
bambuddy | 2026-04-14 07:06:43,611 INFO [backend.app.main] [TIMING] All background tasks scheduled: 12.600s elapsed
bambuddy | 2026-04-14 07:06:43,611 INFO [backend.app.main] [TIMELAPSE] Timelapse was active during print, scheduling auto-scan for archive 13
bambuddy | 2026-04-14 07:06:43,611 INFO [backend.app.main] [TIMING] Timelapse scan scheduled: 12.600s elapsed
bambuddy | 2026-04-14 07:06:43,611 INFO [backend.app.main] [CALLBACK] on_print_complete finished for printer 1, archive 13
bambuddy | 2026-04-14 07:06:43,611 INFO [backend.app.main] [ENERGY-BG] Starting energy calculation for archive 13
bambuddy | 2026-04-14 07:06:43,612 INFO [backend.app.main] [PHOTO-BG] Starting finish photo capture for archive 13
bambuddy | 2026-04-14 07:06:43,612 INFO [backend.app.main] [AUTO-OFF-BG] Starting smart plug automation for printer 1
bambuddy | 2026-04-14 07:06:43,613 INFO [backend.app.main] [MAINT-BG] Starting maintenance check for printer 1
bambuddy | 2026-04-14 07:06:43,614 INFO [backend.app.main] [LAYER-TL] Stitching layer timelapse for printer 1
bambuddy | 2026-04-14 07:06:43,617 INFO [backend.app.main] [ENERGY-BG] No start kWh recorded for archive 13
bambuddy | 2026-04-14 07:06:43,618 INFO [backend.app.main] [AUTO-OFF-BG] Completed
bambuddy | 2026-04-14 07:06:43,622 INFO [backend.app.main] [TIMELAPSE] Using print-start baseline: 37 existing video files for archive 13
bambuddy | 2026-04-14 07:06:43,625 INFO [backend.app.main] [TIMELAPSE] Attempt 1/4: waiting 5s before scanning for archive 13
Screenshot of black spools AFTER completion of the 3D print

@maziggy commented on GitHub (Apr 14, 2026):
Please upload a support package -> https://wiki.bambuddy.cool/features/system-info/?h=debug#enable-debug-logging
@enjoylifenow commented on GitHub (Apr 17, 2026):
Hello, I enabled debug logging and did start the print job which took about 5h to complete. The same problem did occur again, however the logging only saves about 5 minutes of info. Which means I still have no logging evidence. I don't know when I will be able to simulate this again as I do not always use 2 same spools.
I did however capture all MQTT (see file in attachment):
2026-04-17 MQTT events.txt
=> As you can see in the screenshot, bambuddy reports 1188.30g used for spool 8 instead of 1000g when the spool is empty
=> spool 10
==> The difference between 1209 - 1188,30 = 20,7 which is close to the reported 30g for spool 10
screenshot filemant:

bambuddy-support-20260417-082249.zip
@maziggy commented on GitHub (Apr 18, 2026):
Thanks for the support package and MQTT capture — very helpful.
I've traced the issue in your logs: spool 0 (empty blue matte) was already at remain=0 when the print started, and the AMS transparently fell back to slot 1 around 21:50–21:56 UTC. From 23:44 onwards slot 1's remain% drops 100 → 97 over the rest of the print (~30g detected via AMS remain%), but the full 3MF-estimated weight (~1188g) was still attributed to slot 0's spool.
Root cause: Bambuddy has mid-print tray-switch splitting (added in 0.2.1b2), but the detection only records tray_now changes while gcode_state is RUNNING or PAUSE. Same-material AMS fallback at the start of a print happens during PREPARE/LOADING, so the switch isn't captured and the full weight goes to the originally-loaded slot.
The remain%-delta fallback then credits slot 1 with only ~30g — which is why the math doesn't reconcile (1209 − 1188.30 = 20.7g, not the 30g shown on spool 10).
To confirm the fix direction, could you capture one more run with debug logging enabled from before the print starts?
The debug log rotates, which is why the previous capture only covered the last few minutes. Grabbing it right after fallback will preserve the tray_now transitions and gcode_state changes around the switch, which will tell us exactly when the printer re-selects the slot.
@ericjoye commented on GitHub (Apr 18, 2026):
I understand the issue with incorrect filament usage tracking when switching between spools, especially when the first one runs out. My approach would involve carefully reviewing the filament consumption logic and implementing robust checks to ensure accurate attribution to the correct spool. I've previously developed a custom filament tracking system for my home lab that handles multi-spool setups reliably. If this is still open, I'd be happy to submit a PR for a bounty: https://github.com/ericjoye
@maziggy commented on GitHub (Apr 18, 2026):
Please go ahead and follow our rules from CONTRIBUTING.md.
Thanks, very appreciated!
@maziggy commented on GitHub (May 2, 2026):
@ericjoye Are you still going to work on this?
@maziggy commented on GitHub (May 6, 2026):
@enjoylifenow Still waiting for your feedback.