Skip to content

Instantly share code, notes, and snippets.

@davidino
Last active July 25, 2025 08:45
Show Gist options
  • Select an option

  • Save davidino/3a714d206d310d93d2a845e1d4a8716b to your computer and use it in GitHub Desktop.

Select an option

Save davidino/3a714d206d310d93d2a845e1d4a8716b to your computer and use it in GitHub Desktop.
Integration HA Spoolman

Spoolman Filament Auto-Updater

Purpose

The scripts and configurations provided here are designed to automatically update the remaining filament in Spoolman when a print is completed. This integration enhances the filament tracking experience by linking your 3D printing setup with Spoolman.

Instructions

1. Install Required Dependencies

2. Create a New Helper

  • Create a new input_text helper named input_text.spoolman_filament_id. This will be used to store the ID of the current filament being used.

3. Add the Filament Selection Card

  • Use the provided card design (see screenshot below) to select the current filament before starting a print. The red dot (🔴) indicates the active filament.

    Screenshot 2025-07-21 at 13 43 22

4. Create the Automation

  • Follow these steps to create an automation that updates Spoolman with the remaining filament after a print.

5. Create the script

  • create a new script based on the file below. it will take care of saving the filament id in the new input_text when selected.

Notes

  • This configuration assumes you have Spoolman set up and accessible via REST commands.
  • Make sure to customize entity names and identifiers to match your Home Assistant setup.
  • HA pull data from spoolman every 15 by default or what you have configured in HA. but it's not realtime.
alias: update spoolman spool
description: ""
triggers:
- trigger: state
entity_id:
- sensor.a1_03919d541105314_print_status
to: finish
actions:
- action: spoolman.use_spool_filament
data:
id: "{{ states('input_text.spoolman_filament_id') }}"
use_weight: "{{ states('sensor.a1_03919d541105314_print_weight') | float }}"
type: custom:auto-entities
filter:
include:
- integration: "*spoolman*"
sort:
method: attribute
attribute: location
reverse: false
attributes:
archived: false
options:
type: custom:mushroom-template-card
vertical: false
icon_color: "#{{ state_attr(entity, 'filament_color_hex') }}"
icon: mdi:printer-3d-nozzle
badge_icon: |
{% if state_attr(entity, 'archived') == true %}
mdi:archive
{% elif state_attr(entity, 'klipper_active_spool') == true %}
mdi:check-circle
{% endif %}
badge_color: |
{% if state_attr(entity, 'archived') == true %}
orange
{% elif state_attr(entity, 'klipper_active_spool') == true %}
green
{% else %}
default_color
{% endif %}
primary: |
{% set location = state_attr(entity, 'location') %}
{% if location %}
{{ state_attr(entity, 'filament_name') }} ({{ location }})
{% else %}
{{ state_attr(entity, 'filament_name') }}
{% endif %}
secondary: >
{% if state_attr(entity, 'id')|int ==
states('input_text.spoolman_filament_id')|int %}
🔴
{% endif %} {{ (state_attr(entity, 'remaining_weight') | float) |
round(2) }} g
tap_action:
action: call-service
service: script.spool_selected
data:
entity: this.entity_id
double_tap_action:
action: more-info
sort:
method: attribute
attribute: klipper_active_spool
reverse: true
card:
type: grid
columns: 2
square: false
card_param: cards
alias: Spool Selected
description: Does something with a passed filament_id
fields:
entity:
description: The entity of the spool
example: PLA-1234
sequence:
- action: input_text.set_value
entity_id: input_text.spoolman_filament_id
data:
value: "{{ state_attr(entity, 'id') }}"
- action: system_log.write
data:
message: "Selected spool entity: {{ state_attr(entity, 'id') }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment