Fix external spool AMS mapping causing "Failed to get AMS mapping table" (Issue #213)

When printing with external spool holder (no AMS connected), the printer
reported error [0700-8012] "Failed to get AMS mapping table".

Root cause: The ams_mapping2 calculation for external spool (tray_id=254)
was incorrectly computing ams_id=63, slot_id=2 instead of the required
ams_id=255, slot_id=254.

The fix adds special handling for external spool tray IDs (254 for main
nozzle, 255 for deputy nozzle) which use ams_id=255 with slot_id matching
the tray_id.

Fixes #213
This commit is contained in:
maziggy
2026-02-01 13:57:21 +01:00
parent 88c02565c6
commit 60bb29be2f
+7 -2
View File
@@ -2033,10 +2033,15 @@ class BambuMQTTClient:
for tray_id in ams_mapping:
# Ensure tray_id is an integer (may be string from JSON)
tray_id = int(tray_id) if tray_id is not None else -1
if tray_id == -1 or tray_id == 255:
if tray_id == -1:
# Unmapped filament slot
ams_mapping2.append({"ams_id": 255, "slot_id": 255})
elif tray_id >= 254:
# External spool: 254 = main nozzle, 255 = deputy nozzle
# External spools use ams_id=255 with slot_id matching tray_id
ams_mapping2.append({"ams_id": 255, "slot_id": tray_id})
else:
# Global tray ID = (ams_id * 4) + slot_id
# Regular AMS tray: Global tray ID = (ams_id * 4) + slot_id
ams_id = tray_id // 4
slot_id = tray_id % 4
ams_mapping2.append({"ams_id": ams_id, "slot_id": slot_id})