Spoolman Updater – Automate Filament Tracking

Good to hear that it is running good for now. For the AMS it really depends on how it presents itself within Home Assistant.
Is it the same as AMS 1 but with number 5,6 and so on? So sensor name sensor.ID_PRINTER_ams_1_tray_
If that is the case you only need to adjust the helper and sensor. Also check Spoolman updater GUI if you see the other AMS.
If the sensor names are different, you can either re-name them to match your first AMS (keep in mind that renaming could be reverted back with updates), or you change all the yaml (which might break things :wink: )

So I’m a user that doesn’t use the AMS, or have an android phone so to chatGPT I went.

Was able to stet up a way for spoolman to auto update based on a print from BambuLabs.

:thread: Full Guide: Automatic Spool Tracking for Bambu Lab → Spoolman → Home Assistant

This guide walks through how to integrate:

:white_check_mark: Bambu Lab Printer (A1, P1, X1, etc.)

:white_check_mark: Spoolman (for filament tracking)

:white_check_mark: Home Assistant

:white_check_mark: Automation to update spool usage automatically

After setup, every time a print completes, Spoolman automatically reduces filament weight for the correct spool — no manual data entry needed.


:blue_square: 1. Install Spoolman

Spoolman is a lightweight filament manager accessible via a local browser.

Most users deploy it using Docker:

docker run -d \
  --name=spoolman \
  -p 7912:8000 \
  -v /path/to/data:/home/app/.local/share/spoolman \
  ghcr.io/spoolman/spoolman:latest

After installation:

Open in browser:

http://<your-ip>:7912

Create:

  • Vendors (e.g., eSun, Polymaker, Bambu, etc.)
  • Filaments (color, material, weight, diameter)
  • Spools (actual rolls you own)

Optional but recommended:

Create an extra field called "color" to store the hex color code of each spool.
This allows color matching to work later.


:blue_square: 2. Install the Spoolman Integration in Home Assistant

Home Assistant → Settings → Devices & Services → Add Integration → “Spoolman”

Enter your Spoolman URL:

http://<your-ip>:7912

Home Assistant will auto-create:

  • sensor.spoolman_spool_X (one per spool)
  • sensor.spoolman_filament_X
  • Optional helpers (remaining %, etc.)

Each spool entity includes:

  • weight
  • material
  • vendor
  • location
  • extra color field (if configured)

:blue_square: 3. Enable Bambu Lab Integration in Home Assistant

Home Assistant → Settings → Integrations → Add Integration → Bambu Lab

This provides entities such as:

  • sensor.<printer>_print_weight
  • sensor.<printer>_ext_spool (color info)
  • binary_sensor.<printer>_printing
  • binary_sensor.<printer>_idle
  • etc.

Two important entities:

A. Print weight sensor

sensor.<printer>_print_weight

This gives the weight of filament used in the last completed print.

B. External spool sensor

sensor.<printer>_ext_spool

This provides metadata including the color the printer thinks you are using.


:blue_square: 4. Create a Dynamic “Active Spool ID” Sensor

This template matches the printer’s current filament color to the correct spool in Spoolman automatically.

Add to your Home Assistant YAML:

template:
  - sensor:
      - name: "Active Spool ID"
        unique_id: active_spool_id
        state: >
          {% set bambu_color = (state_attr('sensor.<printer>_ext_spool', 'color') | trim | lower) %}

          {# Find all spoolman spool entities dynamically #}
          {% set spools = states.sensor | selectattr('entity_id', 'match', 'sensor.spoolman_spool_\\d+

What it does:

:heavy_check_mark: Loops through all Spoolman spool entities
:heavy_check_mark: Finds the spool that:

  • has a matching color
  • AND is marked as being loaded in the printer
    :heavy_check_mark: Returns the correct spool ID automatically

This eliminates all manual spool swapping logic.


:blue_square: 5. Create a REST Command to Update Spoolman

Spoolman supports a REST API.
This command tells Spoolman to deduct a specific weight from a spool:

Add to configuration.yaml:

rest_command:
  spoolman_use_weight:
    url: "http://<your-ip>:7912/api/v1/spool/{{ spool_id }}/use"
    method: put
    headers:
      Content-Type: application/json
    payload: >
      { "use_weight": {{ weight }} }

Now Home Assistant can send filament usage back to Spoolman.


:blue_square: 6. Create Automation: “Update Spool After Print”

Trigger when a print finishes.
Subtract the print weight from the matched spool.

Automation (GUI-friendly YAML):

alias: Update Spoolman After Print
trigger:
  - platform: state
    entity_id: sensor.<printer>_print_weight
    to: ~
condition:
  - condition: template
    value_template: "{{ states('sensor.active_spool_id') not in ['none','unknown',''] }}"
action:
  - service: rest_command.spoolman_use_weight
    data:
      spool_id: "{{ states('sensor.active_spool_id') }}"
      weight: "{{ states('sensor.<printer>_print_weight') }}"
mode: single

What it does:

:heavy_check_mark: Waits for a print to complete
:heavy_check_mark: Reads filament usage from Bambu Lab
:heavy_check_mark: Determines the exact spool loaded into the printer
:heavy_check_mark: Sends the weight to Spoolman
:heavy_check_mark: Updates remaining & used filament automatically


:blue_square: 7. (Optional) Add Location Logic

If you physically move spools around, give each spool a location in Spoolman:

  • “Printer”
  • “Shelf”
  • “Storage”
  • etc.

The template already checks this so only the spool marked as "Printer" is updated.


:blue_square: 8. How the System Works (High-Level Summary)

:arrows_counterclockwise: 1. Bambu Lab prints something

It calculates how many grams of filament were used.

:satellite: 2. Home Assistant receives print_weight

Example:

sensor.<printer>_print_weight = 28.7 g

:art: 3. Home Assistant reads the spool color from the printer

From:

sensor.<printer>_ext_spool

:brain: 4. Active Spool ID sensor finds the matching spool

It matches:

  • Printer color
  • Spool color
  • Location “Printer”

:link: 5. REST command sends usage to Spoolman

Spoolman updates:

  • used_weight
  • remaining_weight
  • last_used
  • statistics

:tada: 6. Everything stays perfectly in sync

You never manually adjust spools again — it’s fully automatic.) | list %}

      {% for s in spools %}
        {% set loc = s.attributes.location %}
        {% set color = s.attributes.extra_color | default('', true) | trim | lower %}
        {% if loc == "Printer" and color == bambu_color %}
          {{ s.attributes.id }}
          {% break %}
        {% endif %}
      {% endfor %}

### What it does:

✔ Loops through all Spoolman spool entities
✔ Finds the spool that:

* has a matching color
* AND is marked as being loaded in the printer
✔ Returns the correct spool ID automatically

This eliminates all manual spool swapping logic.

---

# 🟦 **5. Create a REST Command to Update Spoolman**

Spoolman supports a REST API.
This command tells Spoolman to deduct a specific weight from a spool:

### Add to `DISCOURSE_PLACEHOLDER_14`:

DISCOURSE_PLACEHOLDER_15


Now Home Assistant can send filament usage back to Spoolman.

---

# 🟦 **6. Create Automation: “Update Spool After Print”**

Trigger when a print finishes.
Subtract the print weight from the matched spool.

### Automation (GUI-friendly YAML):

DISCOURSE_PLACEHOLDER_16


### What it does:

✔ Waits for a print to complete
✔ Reads filament usage from Bambu Lab
✔ Determines the exact spool loaded into the printer
✔ Sends the weight to Spoolman
✔ Updates remaining & used filament automatically

---

# 🟦 **7. (Optional) Add Location Logic**

If you physically move spools around, give each spool a location in Spoolman:

* "Printer"
* "Shelf"
* "Storage"
* etc.

The template already checks this so only the spool marked as `DISCOURSE_PLACEHOLDER_17` is updated.

---

# 🟦 **8. How the System Works (High-Level Summary)**

### 🔄 **1. Bambu Lab prints something**

It calculates how many grams of filament were used.

### 📡 **2. Home Assistant receives print_weight**

Example:

DISCOURSE_PLACEHOLDER_18


### 🎨 **3. Home Assistant reads the spool color from the printer**

From:

DISCOURSE_PLACEHOLDER_19


### 🧠 **4. Active Spool ID sensor finds the matching spool**

It matches:

* Printer color
* Spool color
* Location “Printer”

### 🔗 **5. REST command sends usage to Spoolman**

Spoolman updates:

* used_weight
* remaining_weight
* last_used
* statistics

### 🎉 **6. Everything stays perfectly in sync**

You never manually adjust spools again — it’s fully automatic.
1 Like

This is basically what spoolmanUpdater does. But with spoolmanUpdater its a lot simpeler. Feel free to use your solution but be prepared for the questions people going to ask you about it. It can be overwhelming

Good solution, although I see some kinks. If you have multiple spools in spoolman for example: Esun PLA+ Black. 2 are unused and 1 is used and needs to be updated. This yaml is targeting the color loaded, so which spool will it update :wink:
If you are looking to work with spoolman updater and only the external spool, I already created that script. But as it is not 100% tested, it hasn’t be published on GIT.

1 Like

Hello together,

I spent hours trying to figure out why I kept getting a “404 Not Found” error, until I finally noticed a small typo in APPLICATION__HOMEASSISTANT__EXTERNALSPOOLENTITY.

Wrong:
p1s_SERIAL_externalspool_externe_spule

Correct:
sensor.p1s_SERIAL_externalspool_externe_spule

For reference, this is my Docker Compose configuration:

version: "3.8"

services:
  spoolman-updater:
    image: marcokreeft/spoolman-updater:latest
    container_name: spoolman-updater
    ports:
      - "8088:8080"
    environment:
      - APPLICATION__HOMEASSISTANT__URL=https://my-ha.mydomain.com
      - APPLICATION__HOMEASSISTANT__TOKEN=thisismysupersecrettoken
      - APPLICATION__SPOOLMAN__URL=https://spoolman.mydomain.com
      - APPLICATION__HOMEASSISTANT__AMSENTITIES__0=P1S_SERIAL_AMS_1
      - APPLICATION__HOMEASSISTANT__EXTERNALSPOOLENTITY=sensor.p1s_SERIAL_externalspool_externe_spule
    restart: unless-stopped

Next step: checking whether everything works as expected. :sweat_smile:

Thanks a lot for your work so far!

2 Likes

Does anyone here use the QR code scanning feature in Spoolman Updater? Is it currently working, or is there a bug?

When I go to “Show label” for a spool in Spoolman and scan the QR code with my phone in Spoolman Updater, the following page opens:

However, when I click something there, the active_tray variable for that spool is not updated. If I assign a spool to a tray directly in the GUI, the variable is set without any issues.

I’m running Spoolman Updater behind an NPM reverse proxy; without it, the scanning feature doesn’t work in the browser at all for security reasons.

Spoolman Updater version: 202506071130

1 Like

Hi everyone,

I wanted to share a small proof of concept I’ve been working on around Spoolman Updater and Home Assistant.

I uploaded a short YouTube video where I demonstrate how I assign filament spools to locations (and AMS trays) by simply scanning QR codes. The automation updates the spool location in Spoolman and Spoolman Updater automatically. For example assigning a spool directly to a specific AMS slot on my Bambu Lab printer.

This is just a PoC, but it already works quite reliably in my setup.

If there is interest from the community, I’m happy to share the Home Assistant automation and configuration I’m using. I’d also very much welcome feedback or improvements from others - especially since the current version does not yet support external spools, mainly because I don’t use them very often myself.

Thanks for building and maintaining Spoolman Updater!
It made experiments like this much easier

1 Like

Nice to make use of HA scanning ability :slight_smile:
Although I am a bit confused about the use case. As you need to go to HA to scan the QR code en then scan the code for the tray, right? Is this faster then select the spool in the updater?

1 Like

Hey @Lucrezia,

yes, scanning QR codes is much faster for me than manually setting the spool location in Spoolman. I do use Spoolman’s built-in scanning feature at another building, but at home I’m sticking with my own solution.

BR,
Julian

I do like what you have done but I am just wondering :wink:
Does each spool has it’s own QR code or something? Can’t seem to find that out in the video.

1 Like

Yes, each spool has it’s own QR code, but you could also use NFC tags instead.

On the inside of the doors, you can see my QR codes for the locations. The QR codes for the spools themselves are attached directly to the spool and also to the package (if it still exists).

I just noticed this now …

No, you can just scan the QR code with your camera app and that’s it. No need to open Home Assistant for that.

The tag contains a link like https://www.home-assistant.io/tag/web+spoolman:s:32.

The Home Assistant companion app will recognize and handle it automatically! :ok_hand:

could you share the automation please?

1 Like

hello how to get this ui?

@platini76 I opened a separate topic for this in the forum, have a look here:

I was experiencing this as well. I noticed in the browser console there was a wasm file associated with the QR code reader package (ngx-scanner-qrcode) that was not being found. After a little research I found that there is a LOAD_WASM function from this package that needs to be called to create this wasm file. Without it, the QR codes could not be parsed. In addition, the existing QR code scanning logic did not work with the Spoolman QR codes (it was only setup to use the Barcode field in Spoolman).

I’ve created a PR in the Github repo to fix this and also included better error messages when a QR code cannot be properly parsed.

1 Like