Spoolman Updater – Automate Filament Tracking
Hi everyone!
I’ve built Spoolman Updater, an API that integrates Spoolman with Home Assistant, making it easy to track filament usage automatically. If you’re using a Bambu Lab AMS or any other setup that tracks filament consumption, this tool will help keep your spool database up-to-date.
Features:
Automatic filament tracking – updates spool usage when a print finishes or an AMS tray switches
Home Assistant integration via REST commands
Works with Bambu Lab AMS (requires ha-bambulab integration)
Requires Spoolman (GitHub) to manage filament spools
Lightweight Docker-based API
Fetch spools by brand and color for easy tracking
Requirements
- Spoolman installed and running
- ha-bambulab installed in Home Assistant
- Home Assistant REST commands enabled
How It Works
Deploy Spoolman
Before using Spoolman Updater, you need to install and run Spoolman:
Spoolman Installation Guide
Deploy the API with Docker
docker run -d -p 8088:8080 \
-e APPLICATION__HOMEASSISTANT__URL=http://homeassistant.local \
-e APPLICATION__HOMEASSISTANT__TOKEN=your-token \
-e APPLICATION__SPOOLMAN__URL=http://spoolman.local \
--name spoolman-updater marcokreeft/spoolman-updater
Add this REST command to configuration.yaml
rest_command:
update_spool:
url: "http://<your-server>:8088/Spools/spool"
method: POST
headers:
Content-Type: "application/json"
payload: >
{
"name": "{{ name }}",
"material": "{{ material }}",
"tagUid": "{{ tag_uid }}",
"usedWeight": {{ used_weight }},
"color": "{{ color }}"
}
Create an automation to trigger updates
alias: Update Spool When Print Finishes or Tray Switches
trigger:
- platform: state
entity_id: sensor.x1c_print_status
to: "idle"
- platform: state
entity_id: sensor.x1c_active_tray_index
condition:
- condition: template
value_template: "{{ states('sensor.x1c_active_tray_index') | int > 0 }}"
action:
- variables:
tray_number: "{{ trigger.to_state.state if trigger.entity_id == 'sensor.x1c_active_tray_index' else states('sensor.x1c_active_tray_index') }}"
tray_sensor: "sensor.x1c_ams_tray_{{ tray_number }}"
tray_weight: "{{ state_attr('sensor.x1c_print_weight', 'AMS 1 Tray ' ~ tray_number) | float(0) }}"
tag_uid: "{{ state_attr(tray_sensor, 'tag_uid') }}"
material: "{{ state_attr(tray_sensor, 'type') }}"
name: "{{ state_attr(tray_sensor, 'name') }}"
color: "{{ state_attr(tray_sensor, 'color') }}"
- service: rest_command.update_spool
data:
name: "{{ name }}"
material: "{{ material }}"
tag_uid: "{{ tag_uid }}"
used_weight: "{{ tray_weight }}"
color: "{{ color }}"
More Info
GitHub Repository: Spoolman Updater
Docker Hub: marcokreeft/spoolman-updater
Spoolman (Required!): GitHub
Home Assistant BambuLab Integration: ha-bambulab
Would love to hear your feedback and see how you’re using it! Let me know if you have any questions or improvements.
This post was definitely not generated by ChatGPT.
Oh and it’s not tested through and through so please don’t yell at me if it breaks