Home Assistant Filament Tracking: Spool Weight & Print Hours

With our API integration, you can fully automate tracking your filament usage and printer operating hours. When you start a print, Home Assistant notifies 3D Print Manager and the planned grams come off the mounted spool; when it finishes, the job closes and the hours are logged, and a stopped or failed print gives the unprinted part back.

Note: This guide uses the popular Home Assistant Bambu Lab integration syntax, but the logic can be adapted for Prusa, Creality, etc. Bambu Lab printer not in Home Assistant yet? Start with the Bambu Lab Home Assistant setup guide. 3D Print Manager does not control your printer. It never starts, stops or sends print jobs — it only records the filament usage and operating hours that Home Assistant reports. Your slicer and printer apps stay in charge of printing. Easier without Home Assistant: on a PRO or FARM plan, 3DPM Agent for Windows (Microsoft Store) books Bambu Lab, Prusa (PrusaLink) and Klipper (Moonraker) prints without Home Assistant. Setup: chapter 7b of the user manual. This guide is for printers you already run through Home Assistant and for other brands.

1. Generate your API Key PRO

Before connecting Home Assistant, you need a secret key for communication.

  • Log into 3D Print Manager.
  • Open Settings (gear icon in the menu).
  • Find the API Access section and click Generate New API Key.
  • Copy the generated key (you will need it in Step 3).

2. Copy your Printer ID

The app needs to know exactly which printer the data is coming from.

  • In 3D Print Manager, open the Manage Printers tool.
  • Next to your printer's name, click the fingerprint icon ().
  • You have now copied the unique Printer ID to your clipboard. Save it for later.

3. Add commands to configuration.yaml

Open your Home Assistant configuration.yaml file and add the following rest_command block.

Important: Replace <YOUR_API_KEY> with the key you generated in Step 1!

rest_command:
  # Command to start the print
  3dpm_start_print:
    url: "https://3dprintmanager.eu/api.php?key=<YOUR_API_KEY>&action=start_print"
    method: POST
    headers:
      content_type: 'application/json'
    payload: >-
      {
        "printer_id": "{{ printer_id }}",
        "job_name": "{{ job_name | replace('\"', '\\\"') }}",
        "duration_minutes": {{ duration | int(0) }},
        "mapping": {{ mapping | default('[]') }}
      }

  # Command to finish the print
  3dpm_finish_print:
    url: "https://3dprintmanager.eu/api.php?key=<YOUR_API_KEY>&action=finish_print"
    method: POST
    headers:
      content_type: 'application/json'
    payload: >-
      {
        "printer_id": "{{ printer_id }}",
        "slot": {{ slot | int(-1) }},
        "amount_used": {{ amount | float(0) }},
        "hours": {{ hours | float(0) }}
      }

  3dpm_fail_print:
    url: "https://3dprintmanager.eu/api.php?key=<YOUR_API_KEY>&action=fail_print"
    method: POST
    headers:
      content_type: 'application/json'
    payload: >-
      {
        "printer_id": "{{ printer_id }}",
        "progress": {{ progress | float(-1) }}
      }

Save the file and restart Home Assistant (or Reload REST entities).

4. Add Automations

Now you need to tell Home Assistant when to call these commands. Create two new automations in YAML mode.

Adjust 2 things:
1. Replace your_printer_name with the actual entity ID of your printer.
2. Replace <YOUR_PRINTER_ID> with the ID from Step 2.

Automation 1: Start Print

alias: "3DPM: Start Print"
description: Sends the exact time and filament mapping to 3D Print Manager
triggers:
  - entity_id: sensor.your_printer_name_print_status
    to: running
    trigger: state
actions:
  - wait_template: >-
      {{ state_attr('sensor.your_printer_name_active_tray', 'tray_index') | int(-1) >= 0 }}
    timeout: "00:05:00"
    continue_on_timeout: true
  - delay: "00:00:05"
  - data:
      printer_id: "<YOUR_PRINTER_ID>"
      job_name: "{{ states('sensor.your_printer_name_gcode_file') }}"
      duration: >-
        {{ (states('sensor.your_printer_name_remaining_time') | float(0) * 60) | round(0) }}
      mapping: >-
        {% set tray = state_attr('sensor.your_printer_name_active_tray', 'tray_index') | int(-1) %}  
        {% set slot = 0 if tray in [254, -1] else tray + 1 %}  
        {% set weight = states('sensor.your_printer_name_print_weight') | replace('g', '') | trim | float(0) | round(2) %}  
        [{"slot": {{ slot }}, "weight": {{ weight }}}]
    action: rest_command.3dpm_start_print
mode: single

Automation 2: Finish Print

alias: "3DPM: Finish Print"
description: Deducts grams from the spool and logs operating hours
triggers:
  - entity_id: sensor.your_printer_name_print_status
    to: finish
    trigger: state
actions:
  - data:
      printer_id: "<YOUR_PRINTER_ID>"
      slot: >-
        {% set tray = state_attr('sensor.your_printer_name_active_tray', 'tray_index') | int(-1) %}
        {{ 0 if tray in [254, -1] else tray + 1 }}
      amount: >-
        {{ states('sensor.your_printer_name_print_weight') | replace('g', '') | trim | float(0) | round(2) }}
      hours: 0
    action: rest_command.3dpm_finish_print
mode: single

Automation 2b: Failed or Cancelled Print

A print you stop on the printer, or one that fails, arrives as failed. 3D Print Manager gives back the filament that was not printed, using the progress the printer reported.

alias: "3DPM: Failed or Cancelled Print"
description: Returns unused filament to the spool when a print is cancelled or fails
triggers:
  - entity_id: sensor.your_printer_name_print_status
    to: failed
    trigger: state
actions:
  - data:
      printer_id: "<YOUR_PRINTER_ID>"
      progress: "{{ states('sensor.your_printer_name_print_progress') | float(-1) }}"
    action: rest_command.3dpm_fail_print
mode: single

How to handle Multi-Color prints?

Bambu Lab printers: use 3DPM Agent (PRO or FARM).

The Agent books multi-colour prints per AMS slot: each spool is charged the grams the slicer planned for it. A printer fed by the Agent is ignored by the Home Assistant integration, so nothing is deducted twice.


With Home Assistant only:

Home Assistant cannot read the gram breakdown for each color from the G-code via MQTT, so it deducts the weight only from the spool that was active when the print started. For multi-color prints, turn off the HA automation and use Drag & Drop G-code inside 3D Print Manager to subtract each color.

Praćenje filamenta kroz Home Assistant: težina role i sati printa

Pomoću naše API integracije možete potpuno automatizirati praćenje potrošnje filamenta i radnih sati vaših printera. Kada pokrenete print, Home Assistant javi 3D Print Manageru da je posao počeo i planirani grami se skinu s montirane role. Na kraju se posao zatvori i zabilježe sati, a zaustavljeni ili neuspjeli print vraća neisprintani dio na rolu.

Napomena: Ovaj vodič koristi sintaksu popularne Home Assistant Bambu Lab integracije, ali logika se može prilagoditi za Prusa, Creality itd. Bambu Lab printer još nije u Home Assistantu? Krenite od vodiča za postavljanje Bambu Lab printera u Home Assistant. 3D Print Manager ne upravlja vašim printerom. Nikada ne pokreće, ne zaustavlja niti šalje poslove — samo bilježi potrošnju filamenta i radne sate koje javi Home Assistant. Vaš slicer i aplikacije printera ostaju zaduženi za printanje. Jednostavnije bez Home Assistanta: uz PRO ili FARM plan 3DPM Agent za Windows (Microsoft Store) knjiži printove s Bambu Lab, Prusa (PrusaLink) i Klipper (Moonraker) printera bez Home Assistanta. Postavljanje: poglavlje 7b korisničkog priručnika. Ovaj vodič je za printere koje već vodite kroz Home Assistant i za ostale marke.

1. Generirajte svoj API ključ PRO

Prije povezivanja s Home Assistantom, potreban vam je tajni ključ za komunikaciju.

  • Prijavite se u 3D Print Manager.
  • Otvorite Postavke (Settings) (ikona zupčanika u izborniku).
  • Pronađite sekciju API Access i kliknite Generate New API Key.
  • Kopirajte generirani ključ (trebat će vam u Koraku 3).

2. Kopirajte ID vašeg printera

Aplikacija mora znati točno s kojeg printera dolaze podaci.

  • U 3D Print Manageru otvorite alat za upravljanje printerima (Manage Printers).
  • Pored imena vašeg printera kliknite na ikonu otiska prsta ().
  • Ovime ste kopirali jedinstveni ID printera u međuspremnik. Zapišite ga sa strane.

3. Dodajte komande u configuration.yaml

Otvorite svoju configuration.yaml datoteku u Home Assistantu i dodajte rest_command blok.

Važno: Zamijenite <TVOJ_API_KLJUC> s ključem koji ste dobili u Koraku 1!

rest_command:
  # Komanda za pocetak printa
  3dpm_start_print:
    url: "https://3dprintmanager.eu/api.php?key=<TVOJ_API_KLJUC>&action=start_print"
    method: POST
    headers:
      content_type: 'application/json'
    payload: >-
      {
        "printer_id": "{{ printer_id }}",
        "job_name": "{{ job_name | replace('\"', '\\\"') }}",
        "duration_minutes": {{ duration | int(0) }},
        "mapping": {{ mapping | default('[]') }}
      }

  # Komanda za kraj printa
  3dpm_finish_print:
    url: "https://3dprintmanager.eu/api.php?key=<TVOJ_API_KLJUC>&action=finish_print"
    method: POST
    headers:
      content_type: 'application/json'
    payload: >-
      {
        "printer_id": "{{ printer_id }}",
        "slot": {{ slot | int(-1) }},
        "amount_used": {{ amount | float(0) }},
        "hours": {{ hours | float(0) }}
      }

  3dpm_fail_print:
    url: "https://3dprintmanager.eu/api.php?key=<YOUR_API_KEY>&action=fail_print"
    method: POST
    headers:
      content_type: 'application/json'
    payload: >-
      {
        "printer_id": "{{ printer_id }}",
        "progress": {{ progress | float(-1) }}
      }

Spremite datoteku i ponovno pokrenite Home Assistant (ili napravite Reload REST entities).

4. Dodajte Automacije

Sada trebate reći HA kada da pozove ove komande. Kreirajte dvije nove automacije u YAML modu.

Važno (Prilagodite 2 stvari):
1. Svugdje gdje piše tvoj_printer, zamijenite to sa stvarnim imenom vašeg printera u HA.
2. Zamijenite <TVOJ_PRINTER_ID> s ID-jem iz Koraka 2.

Automacija 1: Početak Printa

alias: "3DPM: Start Print"
description: Javlja 3D Print Manageru točno vrijeme i mapiranje filamenta
triggers:
  - entity_id: sensor.tvoj_printer_print_status
    to: running
    trigger: state
actions:
  - wait_template: >-
      {{ state_attr('sensor.tvoj_printer_active_tray', 'tray_index') | int(-1) >= 0 }}
    timeout: "00:05:00"
    continue_on_timeout: true
  - delay: "00:00:05"
  - data:
      printer_id: "<TVOJ_PRINTER_ID>"
      job_name: "{{ states('sensor.tvoj_printer_gcode_file') }}"
      duration: >-
        {{ (states('sensor.tvoj_printer_remaining_time') | float(0) * 60) | round(0) }}
      mapping: >-
        {% set tray = state_attr('sensor.tvoj_printer_active_tray', 'tray_index') | int(-1) %}  
        {% set slot = 0 if tray in [254, -1] else tray + 1 %}  
        {% set weight = states('sensor.tvoj_printer_print_weight') | replace('g', '') | trim | float(0) | round(2) %}  
        [{"slot": {{ slot }}, "weight": {{ weight }}}]
    action: rest_command.3dpm_start_print
mode: single

Automacija 2: Završetak Printa

alias: "3DPM: Finish Print"
description: Skida grame s role i upisuje radne sate printeru na kraju
triggers:
  - entity_id: sensor.tvoj_printer_print_status
    to: finish
    trigger: state
actions:
  - data:
      printer_id: "<TVOJ_PRINTER_ID>"
      slot: >-
        {% set tray = state_attr('sensor.tvoj_printer_active_tray', 'tray_index') | int(-1) %}
        {{ 0 if tray in [254, -1] else tray + 1 }}
      amount: >-
        {{ states('sensor.tvoj_printer_print_weight') | replace('g', '') | trim | float(0) | round(2) }}
      hours: 0
    action: rest_command.3dpm_finish_print
mode: single

Automacija 2b: Neuspjeli ili otkazani print

Print koji zaustaviš na printeru, ili koji ne uspije, stiže kao failed. 3D Print Manager vraća na rolu filament koji nije isprintan, prema napretku koji je printer javio.

alias: "3DPM: Failed or Cancelled Print"
description: Vraca neiskoristeni filament na rolu kad je print otkazan ili neuspio
triggers:
  - entity_id: sensor.tvoj_printer_print_status
    to: failed
    trigger: state
actions:
  - data:
      printer_id: "<TVOJ_PRINTER_ID>"
      progress: "{{ states('sensor.tvoj_printer_print_progress') | float(-1) }}"
    action: rest_command.3dpm_fail_print
mode: single

Kako raditi s Multi-Color printevima?

Bambu Lab printeri: koristite 3DPM Agent (PRO ili FARM).

Agent knjiži višebojne printeve po AMS slotu: svaka rola dobiva grame koje je slicer za nju planirao. Printer koji puni Agent Home Assistant integracija preskače, pa se ništa ne oduzima dvaput.


Samo s Home Assistantom:

Home Assistant ne može preko MQTT-a pročitati potrošnju svake boje iz G-codea, pa ukupnu težinu skida samo s role koja je bila aktivna na početku printa. Za višebojne printeve isključite HA automatizaciju i koristite Drag & Drop G-code u 3D Print Manageru da se točno skine svaka boja.

Filament-Tracking mit Home Assistant: Spulengewicht und Druckstunden

Mit unserer API-Integration können Sie die Verfolgung Ihres Filamentverbrauchs und der Druckerbetriebsstunden vollständig automatisieren. Wenn Sie einen Druck starten, benachrichtigt Home Assistant den 3D Print Manager und die geplanten Gramm werden von der Rolle abgezogen. Am Ende wird der Auftrag abgeschlossen und die Stunden erfasst; ein gestoppter oder fehlgeschlagener Druck bucht den nicht gedruckten Teil zurück.

Hinweis: Diese Anleitung verwendet die Syntax der beliebten Home Assistant Bambu Lab Integration, aber die Logik kann für Prusa, Creality usw. angepasst werden. Ihr Bambu-Lab-Drucker ist noch nicht in Home Assistant? Beginnen Sie mit der Anleitung für Bambu Lab in Home Assistant. 3D Print Manager steuert Ihren Drucker nicht. Er startet, stoppt oder sendet niemals Druckaufträge — er erfasst nur den von Home Assistant gemeldeten Filamentverbrauch und die Betriebsstunden. Ihr Slicer und die Drucker-Apps bleiben für das Drucken zuständig. Einfacher ohne Home Assistant: mit einem PRO- oder FARM-Plan bucht 3DPM Agent für Windows (Microsoft Store) Drucke von Bambu-Lab-, Prusa- (PrusaLink) und Klipper-Druckern (Moonraker) ohne Home Assistant. Einrichtung: Kapitel 7b des Benutzerhandbuchs. Diese Anleitung ist für Drucker, die Sie bereits über Home Assistant betreiben, und für andere Marken.

1. API-Schlüssel generieren PRO

Bevor Sie Home Assistant verbinden, benötigen Sie einen geheimen Schlüssel für die Kommunikation.

  • Melden Sie sich im 3D Print Manager an.
  • Öffnen Sie die Einstellungen (Settings) (Zahnrad-Symbol im Menü).
  • Suchen Sie den Abschnitt API Access und klicken Sie auf Generate New API Key.
  • Kopieren Sie den generierten Schlüssel (Sie benötigen ihn in Schritt 3).

2. Kopieren Sie Ihre Drucker-ID

Die App muss genau wissen, von welchem Drucker die Daten kommen.

  • Öffnen Sie im 3D Print Manager das Tool zur Druckerverwaltung (Manage Printers).
  • Klicken Sie neben dem Namen Ihres Druckers auf das Fingerabdruck-Symbol ().
  • Sie haben nun die eindeutige Drucker-ID in Ihre Zwischenablage kopiert. Speichern Sie diese.

3. Befehle zu configuration.yaml hinzufügen

Öffnen Sie Ihre Home Assistant configuration.yaml Datei und fügen Sie den rest_command Block hinzu.

Wichtig: Ersetzen Sie <IHR_API_SCHLUSSEL> durch den in Schritt 1 generierten Schlüssel!

rest_command:
  # Befehl zum Starten des Drucks
  3dpm_start_print:
    url: "https://3dprintmanager.eu/api.php?key=<IHR_API_SCHLUSSEL>&action=start_print"
    method: POST
    headers:
      content_type: 'application/json'
    payload: >-
      {
        "printer_id": "{{ printer_id }}",
        "job_name": "{{ job_name | replace('\"', '\\\"') }}",
        "duration_minutes": {{ duration | int(0) }},
        "mapping": {{ mapping | default('[]') }}
      }

  # Befehl zum Beenden des Drucks
  3dpm_finish_print:
    url: "https://3dprintmanager.eu/api.php?key=<IHR_API_SCHLUSSEL>&action=finish_print"
    method: POST
    headers:
      content_type: 'application/json'
    payload: >-
      {
        "printer_id": "{{ printer_id }}",
        "slot": {{ slot | int(-1) }},
        "amount_used": {{ amount | float(0) }},
        "hours": {{ hours | float(0) }}
      }

  3dpm_fail_print:
    url: "https://3dprintmanager.eu/api.php?key=<YOUR_API_KEY>&action=fail_print"
    method: POST
    headers:
      content_type: 'application/json'
    payload: >-
      {
        "printer_id": "{{ printer_id }}",
        "progress": {{ progress | float(-1) }}
      }

Speichern Sie die Datei und starten Sie Home Assistant neu.

4. Automatisierungen hinzufügen

Jetzt müssen Sie Home Assistant mitteilen, wann diese Befehle aufgerufen werden sollen. Erstellen Sie zwei neue Automatisierungen im YAML-Modus.

2 Dinge anpassen:
1. Ersetzen Sie überall ihr_drucker durch den tatsächlichen Namen Ihres Druckers in HA.
2. Ersetzen Sie <IHRE_DRUCKER_ID> durch die ID aus Schritt 2.

Automatisierung 1: Druck Starten

alias: "3DPM: Start Print"
description: Sendet die genaue Zeit und das Filament-Mapping an 3D Print Manager
triggers:
  - entity_id: sensor.ihr_drucker_print_status
    to: running
    trigger: state
actions:
  - wait_template: >-
      {{ state_attr('sensor.ihr_drucker_active_tray', 'tray_index') | int(-1) >= 0 }}
    timeout: "00:05:00"
    continue_on_timeout: true
  - delay: "00:00:05"
  - data:
      printer_id: "<IHRE_DRUCKER_ID>"
      job_name: "{{ states('sensor.ihr_drucker_gcode_file') }}"
      duration: >-
        {{ (states('sensor.ihr_drucker_remaining_time') | float(0) * 60) | round(0) }}
      mapping: >-
        {% set tray = state_attr('sensor.ihr_drucker_active_tray', 'tray_index') | int(-1) %}  
        {% set slot = 0 if tray in [254, -1] else tray + 1 %}  
        {% set weight = states('sensor.ihr_drucker_print_weight') | replace('g', '') | trim | float(0) | round(2) %}  
        [{"slot": {{ slot }}, "weight": {{ weight }}}]
    action: rest_command.3dpm_start_print
mode: single

Automatisierung 2: Druck Beenden

alias: "3DPM: Finish Print"
description: Zieht Gramm von der Rolle ab und protokolliert Betriebsstunden
triggers:
  - entity_id: sensor.ihr_drucker_print_status
    to: finish
    trigger: state
actions:
  - data:
      printer_id: "<IHRE_DRUCKER_ID>"
      slot: >-
        {% set tray = state_attr('sensor.ihr_drucker_active_tray', 'tray_index') | int(-1) %}
        {{ 0 if tray in [254, -1] else tray + 1 }}
      amount: >-
        {{ states('sensor.ihr_drucker_print_weight') | replace('g', '') | trim | float(0) | round(2) }}
      hours: 0
    action: rest_command.3dpm_finish_print
mode: single

Automatisierung 2b: Fehlgeschlagener oder abgebrochener Druck

Ein am Drucker gestoppter oder fehlgeschlagener Druck kommt als failed an. 3D Print Manager bucht das nicht gedruckte Filament anhand des gemeldeten Fortschritts auf die Spule zurück.

alias: "3DPM: Failed or Cancelled Print"
description: Bucht ungenutztes Filament zurueck, wenn ein Druck abgebrochen wird oder fehlschlaegt
triggers:
  - entity_id: sensor.ihr_drucker_print_status
    to: failed
    trigger: state
actions:
  - data:
      printer_id: "<IHRE_DRUCKER_ID>"
      progress: "{{ states('sensor.ihr_drucker_print_progress') | float(-1) }}"
    action: rest_command.3dpm_fail_print
mode: single

Was ist mit mehrfarbigen Drucken?

Bambu-Lab-Drucker: Nutzen Sie 3DPM Agent (PRO oder FARM).

Der Agent bucht mehrfarbige Drucke pro AMS-Slot: Jede Spule bekommt die Gramm, die der Slicer für sie geplant hat. Einen Drucker, den der Agent versorgt, ignoriert die Home-Assistant-Integration, also wird nichts doppelt abgezogen.


Nur mit Home Assistant:

Home Assistant kann die Nutzung jeder Farbe nicht über MQTT aus dem G-Code auslesen und zieht das Gewicht daher nur von der Rolle ab, die beim Start des Drucks aktiv war. Für mehrfarbige Drucke schalten Sie die HA-Automatisierung aus und nutzen Drag & Drop G-Code im 3D Print Manager, um jede Farbe genau abzuziehen.