Thanks, Tom, this is EXTREMELY helpful! I appreciate you doing this testing and providing all these logs from your 2 AMS setup.
I’m busy the next few days but will try to push a fix later this week or this weekend and will post back here when I have a fix sorted out. Thanks again!!
I’ve just pushed updates that address both issues you reported.
Changelog
Fixed: Cancelled print not tracking filament usage (Issue #1)
Problem: When you cancelled a print and then manually unloaded the filament, the accumulated usage wasn’t being logged.
Root cause: The automation was checking if the printer stage was in ['printing', 'prepare', 'pause'] before logging usage on a tray change. When you cancelled and the stage went to 'idle', then unloaded the spool, it skipped logging because it thought you were just doing an idle spool swap.
Fix: Removed the stage check entirely. If there’s accumulated weight on the utility meter when a tray change occurs, that weight represents real filament consumption and should be logged - regardless of what the current printer stage is. The usage is now captured either at the moment you cancel (via PRINT END trigger) or when you unload the spool (via TRAY CHANGE trigger).
Fixed: Multiple AMS units not tracked (Issue #2 - AMS2 problem)
Problem: Only AMS1 trays (1-4) were being tracked. Prints from AMS2, AMS3, or AMS4 would incorrectly report usage from AMS1 trays.
Root cause: The config generator was hardcoding ams_1 in multiple places and completely ignoring any additional AMS units discovered during printer setup.
Fix: Complete rewrite of the automation generator to support up to 4 AMS units. Now uses a composite ID encoding scheme:
0 = external spool
11-14 = AMS1 trays 1-4
21-24 = AMS2 trays 1-4
31-34 = AMS3 trays 1-4
41-44 = AMS4 trays 1-4
The generator now iterates through all discovered AMS units and uses the actual entity IDs from your Home Assistant, so it will correctly handle any entity naming suffixes too.
Updated: Embedded HA now uses ha-bambulab v2.2.20-beta2
The embedded Home Assistant instance now uses ha-bambulab v2.2.20-beta2, which includes a fix for empty tray detection. This should no longer be an issue.
To get the fix
Pull the latest changes / rebuild your container
Go to Settings and click “Configure Automations” to regenerate the HA automations
Home Assistant will restart automatically to load the new configuration
Test a print from AMS2 to verify it tracks correctly!
Let me know if you run into any other issues. Thanks again for the thorough testing!
Hi, I’ve Installed the external version, setup in the interface went fine, HA and Spoolman connect without problems, and the printer shows up in the settings.
The issue is I can’t create any automations, I just get the error “No Bambu Lab printers found. Please ensure ha-bambulab is configured.”
SpoolmanSync is authorized in HA, the bambulab-ha extension works fine (printer is available and can be controlled), no errors from docker logs, no errors through the activity logs.
The only thing I changed in the compose file is a bind for the port, as the 3000 was already used by another container. Shouldn’t be an issue as everything works fine with the bind.
I’m on the latest (9bf7d0e) pull of the repo and ha-bambulab v2.2.20-beta2.
If you need any additional log, let me know.
Thanks, that worked (I’ve should have checked the github issues first).
Unfortunately, the filament usage isn’t tracked. I tried with two spools, three different prints. The automation runs when it should, but it doesn’t return any weight. You can find the two traces for Update Spool here: SpoolmanSync Traces - Pastebin.com
I think it’s reading the weight value after utility_meter is set to 0.
Let me know if you need anything else.
EDIT: found it, it was the localization again. Fixed it manually. I’ve just seen that you already fixed in source. Man, I really need to start reading issues fully.
Moved spool with unknown Serial from AMS1 Tray 4 → AMS1 Tray 3
AM1 Tray 3 was correctly detected empty at startup of SpoolmanSync and HA
Old tray (AMS1 Tray 4) is now empty, but SpoolmanSync still shows: "AMS 1 Tray 4 has filament but no assigned spool. "
Feature Request (Optional)
Activity Log of SpoolmanSync: Show all tray changes
Currently only logs when SpoolmanSync takes action. Would be helpful to see ALL detected tray change events (even without auto-assignment) directly in SpoolmanSync instead of checking Portainer/HA logs. But it’s only nice-to-have.
Still testing: Aborted prints workflow. “Unfortunately” I didn’t have to abort a print in the last view days.
Feature Request Implemented
I’ve updated SpoolmanSync to now log ALL tray change events in the Logs tab - including empty tray detections even when no action is taken. There’s also a new “Tray Changes” filter to easily see just these events. This should make debugging much easier.
Empty Tray Detection Issue
I wasn’t able to reproduce this on my end - when I remove a spool, SpoolmanSync correctly detects it as empty. This suggests the issue is likely on the Home Assistant side where ha-bambulab isn’t updating the tray entity to “Empty” during runtime.
To confirm: next time this happens, can you check HA → Developer Tools → States and search for the tray entity (e.g., sensor.xxx_ams_1_tray_4)? If the name attribute still shows the old filament name instead of “Empty”, then ha-bambulab isn’t clearing the tray data properly.
Let me know what you find and we can go from there!