Fix Bambu Lab spool detection in Spoolman sync and AMS cards

The spool detection only checked tray_uuid and tag_uid, but some Bambu Lab
  spools have RFID read issues causing these to be missing while still having
  valid tray_info_idx (Bambu filament preset ID like "GFA00").

  Backend changes (backend/app/services/spoolman.py):
  - Add tray_info_idx to AMSTray dataclass
  - Parse tray_info_idx from raw MQTT data in parse_ams_tray()
  - Check tray_info_idx first in is_bambu_lab_spool() - most reliable indicator
  - Bambu Lab presets start with "GF" (GFA00, GFB00, GFL00, etc.)
  - Fall back to tray_uuid then tag_uid for unique spool identification
  - Add warning when Bambu spool detected but no unique ID for Spoolman

  Backend changes (backend/app/api/routes/spoolman.py):
  - Update /sync/{printer_id} and /sync-all to pass tray_info_idx
  - Guard against empty spool_tag when adding to tracking set

  Frontend changes (frontend/src/pages/PrintersPage.tsx):
  - Add isBambuLabSpool() helper with same detection logic as backend
  - Update all 4 vendor detection locations in AMS cards to use new helper

  Detection priority (same on frontend and backend):
  1. tray_info_idx starts with "GF" (Bambu preset ID)
  2. tray_uuid is valid 32-char hex (non-zero)
  3. tag_uid is valid 16-char hex (non-zero)
This commit is contained in:
maziggy
2026-01-15 16:23:09 +01:00
parent 6eedf55713
commit 61c6473eca
5 changed files with 470 additions and 415 deletions
+6 -4
View File
@@ -213,7 +213,7 @@ async def sync_printer_ams(
location = client.convert_ams_slot_to_location(ams_id, tray.tray_id)
# Skip non-Bambu Lab spools (SpoolEase/third-party) - track as skipped
if not client.is_bambu_lab_spool(tray.tray_uuid, tray.tag_uid):
if not client.is_bambu_lab_spool(tray.tray_uuid, tray.tag_uid, tray.tray_info_idx):
skipped.append(
SkippedSpool(
location=location,
@@ -230,7 +230,8 @@ async def sync_printer_ams(
if tray.tray_uuid and tray.tray_uuid != "00000000000000000000000000000000"
else tray.tag_uid
)
current_tray_uuids.add(spool_tag.upper())
if spool_tag:
current_tray_uuids.add(spool_tag.upper())
try:
sync_result = await client.sync_ams_tray(tray, printer.name)
@@ -342,7 +343,7 @@ async def sync_all_printers(db: AsyncSession = Depends(get_db)):
location = f"{printer.name} - {client.convert_ams_slot_to_location(ams_id, tray.tray_id)}"
# Skip non-Bambu Lab spools (SpoolEase/third-party) - track as skipped
if not client.is_bambu_lab_spool(tray.tray_uuid, tray.tag_uid):
if not client.is_bambu_lab_spool(tray.tray_uuid, tray.tag_uid, tray.tray_info_idx):
all_skipped.append(
SkippedSpool(
location=location,
@@ -359,7 +360,8 @@ async def sync_all_printers(db: AsyncSession = Depends(get_db)):
if tray.tray_uuid and tray.tray_uuid != "00000000000000000000000000000000"
else tray.tag_uid
)
printer_tray_uuids[printer.name].add(spool_tag.upper())
if spool_tag:
printer_tray_uuids[printer.name].add(spool_tag.upper())
try:
sync_result = await client.sync_ams_tray(tray, printer.name)