mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-05-09 05:35:30 +02:00
[PR #277] [MERGED] Feature/accurate usage tracking #983
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#983
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?
📋 Pull Request Information
Original PR: https://github.com/maziggy/bambuddy/pull/277
Author: @bambuman
Created: 2/5/2026
Status: ✅ Merged
Merged: 2/6/2026
Merged by: @maziggy
Base:
0.1.8b← Head:feature/accurate-usage-tracking📝 Commits (8)
6e82cc6Add per-filament Spoolman usage tracking with G-code parsing5703ceafix linting isssues2c086ddruff format changes33b9360pre-commit changes996f788Merge pull request #279 from maziggy/0.1.8b0a39b12Merge branch 'maziggy:main' into feature/accurate-usage-trackingce4683aUse defusedxml in test files for Bandit compliance0dcb154Merge branch '0.1.8b' into feature/accurate-usage-tracking📊 Changes
12 files changed (+1316 additions, -73 deletions)
View changed files
📝
backend/app/api/routes/settings.py(+10 -0)📝
backend/app/api/routes/spoolman.py(+19 -14)📝
backend/app/core/database.py(+21 -0)📝
backend/app/main.py(+463 -52)➕
backend/app/models/active_print_spoolman.py(+42 -0)📝
backend/app/schemas/settings.py(+10 -0)📝
backend/app/services/spoolman.py(+4 -2)➕
backend/app/utils/threemf_tools.py(+307 -0)📝
backend/tests/integration/test_spoolman_api.py(+206 -0)➕
backend/tests/unit/services/test_spoolman_service.py(+174 -0)📝
frontend/src/api/client.ts(+3 -3)📝
frontend/src/components/SpoolmanSettings.tsx(+57 -2)📄 Description
Description
Add per-filament Spoolman usage tracking with G-code parsing.
Implements accurate per-filament usage tracking for Spoolman integration, similar to OpenSpoolman v0.3.0. This replaces the previous single-spool reporting with multi-material aware tracking.
Features:
active_print_spoolmandatabase table (survives server restarts for long prints)Related Issue
Type of Change
Changes Made
backend/app/utils/threemf_tools.py) to extract per-layer, per-filament extrusion data from 3MF filesActivePrintSpoolmandatabase model to persist tracking data across server restartsactive_print_spoolmantable withlayer_usageandfilament_propertiescolumns_store_spoolman_print_data()to capture AMS tray state and G-code data at print start_report_spoolman_usage()to report per-filament usage to correct spools based on slot-to-tray mapping_report_partial_spoolman_usage()to calculate and report partial usage for failed/cancelled prints using G-code layer datasync_ams_tray()to supportdisable_weight_syncparametertest_spoolman_service.py)test_spoolman_api.py)Screenshots
Testing
Testing performed:
Checklist
Additional Notes
Why "Disable AMS Weight Sync"?
The AMS estimates filament remaining by tracking spool rotation speed, NFC tag data, and filament extrusion speed. This estimation can jump up or down by several percent between readings and isn't very accurate. By disabling weight sync, users can rely on Spoolman's more precise usage-based calculations instead.
Partial Usage Reporting:
When a print fails or is cancelled, Bambuddy now calculates how much filament was actually used based on G-code layer data rather than linear interpolation. This is especially important for multi-material prints where different filaments are used on different layers.
Database Persistence:
Tracking data is stored in SQLite rather than memory to survive server restarts. This is important since prints can take many hours or even days.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.