Adds optional Spoolman (https://github.com/Donkie/Spoolman) integration
for live filament consumption tracking.
Config (config.ini [spoolman] section or env vars):
SPOOLMAN_SERVER = http://192.168.x.x:7912
SPOOLMAN_SYNC_RATE = 30 # mid-print sync interval in seconds (0=end only)
How it works:
- Uses supplies_usage from the printer's own MQTT print/report payload —
the printer's cumulative extrusion counter in mm, reset each print.
Discovered via MQTT payload inspection: matches slicer estimate within
~1% for model filament, and also captures the printer's purge/prime
sequence that the slicer doesn't count.
- Reports to Spoolman via PUT /api/v1/spool/{id}/use with use_length (mm),
letting Spoolman convert to weight using the spool's filament profile.
- Accurate for both completed and cancelled prints — no estimation needed.
- For multi-slot prints, total filament is split equally across mapped spools
(v1 approximation; per-slot MQTT breakdown not available).
UI changes:
- Filament assignment dialog gains a Spoolman section (hidden when not
configured): one spool dropdown per assigned AMS slot, loaded async
from GET /kx/spoolman/spools.
- AMS slot display shows a 🧵 #N badge on any slot with a mapped spool.
- Spool assignments persist across prints (sticky until changed).
New API endpoints:
GET /kx/spoolman/status — configured flag, server URL, slot map
GET /kx/spoolman/spools — spool list proxied from Spoolman
POST /kx/spoolman/active-spool — body: {"slot_map": {"0": 42, "1": 17}}
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>