🖨️ + 🏠 + 📊

Bambu Lab Home Assistant Integration: P1S, X1C, A1 Setup

Complete setup guide for automatic filament tracking

Step-by-step tutorial — no prior Home Assistant experience required

Skip Home Assistant: 3DPM Agent

No Home Assistant server and no MQTT setup. 3DPM Agent for Windows (Microsoft Store) books Bambu Lab, Prusa (PrusaLink) and Klipper (Moonraker) prints into 3D Print Manager and takes the grams off the right spools when a print starts; a stopped or failed print gets the unprinted part back. It is included in PRO and FARM. Sign up from this guide and PRO is free for 30 days, no card needed. Setup: chapter 7b of the user manual.

This guide is for printers you already run through Home Assistant and for other brands.

Overview

How does the 3DPM + HA connection work?

Before we start clicking buttons, it's worth understanding what we're actually building — so nothing seems like magic later.

The big picture

Your Bambu P1S printer is on your Wi-Fi network. Home Assistant (HA) connects to it and reads its status in real time — things like "is it printing right now?", "how many grams of filament does the current print use?", "how many minutes are left?".

When the printer's status changes (e.g. from idle to printing), HA fires an automation. That automation calls the 3DPM API — essentially sending a message like "hey, printer just started a 90-minute print using 45g of filament from slot 1". 3DPM receives that, creates a print job record, and deducts the filament from your inventory — all automatically.

Step-by-step data flow


P1S
starts printing
→

Home Assistant
detects status change
→

Automation fires
reads sensor data
→

3DPM API
logs job & deducts

The 5 events we track

Start Print

Triggered when print status changes to running. HA waits a few seconds for the printer to enter the actual printing phase, then reads the filename, estimated duration, and filament weight — and sends all of that to 3DPM, which takes the grams off the mapped spools right away.

Finish Print

Triggered when the print finishes (finish) and closes the job. The grams came off the spools when the print started, so nothing more is deducted here.

Failed or Cancelled Print

Triggered when a print stops or fails (failed). 3DPM closes the job as failed and gives back the grams that were not printed, based on the last progress the printer reported.

Pause Print

Triggered when status changes to pause. Tells 3DPM the job is paused so it can update the status in the scheduler. This also enables the runout detection flow — if filament ran out, 3DPM will flag the job for a spool swap.

Resume Print

Triggered when status changes from pause back to running. HA waits for the AMS tray to be ready, then sends the new remaining time to 3DPM so the job timeline updates correctly.

What is the API key?

The API key is your personal password for the 3DPM API. It proves to 3DPM that the request is coming from your Home Assistant — not from someone else. You'll find it in 3DPM under Settings → API. It looks like a long string of random letters and numbers, e.g. a8058e74d9d8ec984dd29293...

What is the Printer ID?

Each printer you add to 3DPM gets a unique UUID — a long ID that looks like b7b71ff0-1a91-11f1-b989-566fc143004c. This tells the API which printer is printing. You'll find it in 3DPM under Settings → Printers → Edit.

Nothing gets installed on your printer. The P1S doesn't need any firmware modification. HA reads data through the Bambu Cloud or direct local connection — the same way the official Bambu Handy app works. 3DPM only reads this data — it never controls your printer: it does not start, stop, pause or send print jobs. Your slicer and the printer's own apps stay in charge of printing.
Before you start

What you need

  • Home Assistant running (any install type)
  • Bambu P1S on Wi-Fi
  • Bambu account (email + password)
  • 3DPM account (PRO or FARM plan)
  • Printer added in 3DPM under Settings → Printers
  • ~30 minutes of free time
1
HACSInstall HACS

HACS is the Home Assistant Community Store — an app store for unofficial integrations. The Bambu Lab integration lives here, so we need HACS first.

Install the Terminal add-on
  1. Go to Settings → Add-ons → Add-on Store
  2. Search for Terminal & SSH and install it
  3. Click Start then Open Web UI
Run the HACS installer
  1. In the terminal window, paste this exact command and press Enter:
wget -O - https://get.hacs.xyz | bash -
  1. Wait for green output lines — the install is done when you see HACS is now installed
  2. Restart HA: Settings → System → Restart
Activate HACS
  1. After restart go to Settings → Devices & Services → Add Integration
  2. Search for HACS and click it
  3. Accept the terms, then link your GitHub account when prompted (you need a free GitHub account)
Done when: A new HACS item appears in the left sidebar.
2
HACSInstall the Bambu Lab integration

This integration makes HA understand your Bambu printer and creates sensor entities for everything it reports.

  1. Click HACS in the left sidebar
  2. Click the Integrations tab
  3. Click + Explore & Download Repositories
  4. Search: Bambu Lab
  5. Select Bambu Lab by author greghesp
  6. Click Download → confirm
  7. Restart HA: Settings → System → Restart
Check the author! The correct integration is by greghesp. There are forks — make sure you pick the right one.
3
Connect your P1S to Home Assistant
  1. Go to Settings → Devices & Services → Add Integration
  2. Search for Bambu Lab and click it
  3. Choose connection mode:
☁️ Cloud (recommended for beginners)

Enter your Bambu account email and password. Works even if the printer is on a different network. Requires internet.

🏠 Local network

Enter the printer's IP address and Access Code (found in the printer's settings menu). Faster, no cloud dependency.

  1. Enter the required credentials and click Submit
  2. HA will find your P1S and create a device entry
Done when: You see a Bambu Lab card with your printer name under Settings → Devices & Services.
4
Find your P1S entity IDs

Every sensor the Bambu integration creates has a unique entity ID. The automations we'll write need these exact IDs. They follow a pattern:

sensor.p1s_SERIALNUMBER_sensor_name

The serial number part is unique to your printer — like 01p00a461800769.

How to find them
  1. Go to Developer Tools → States (in the HA left sidebar)
  2. In the filter box type: p1s
  3. You'll see all your P1S sensors listed — their entity IDs are on the left
Alternatively: Settings → Devices & Services → Devices → click your printer → scroll through the sensor list and click any sensor to see its entity ID.
The 7 sensors you need
SensorEntity ID ends withExample value
Print status_print_statusrunning, finish, pause, idle
Active AMS tray_active_trayattribute: tray_index = 0,1,2,3
G-code filename_gcode_filemodel.3mf
Remaining time_remaining_time90 (minutes)
Print weight_print_weight45g
Print progress_print_progress0–100
Current stage_current_stageprinting, prepare, idle
Sensor name difference: The G-code filename sensor suffix is not the same for all models. P1S uses _gcode_file. P2S and A1 use _gcode_filename. For other models, check your actual entity ID directly in Home Assistant: go to Settings → Devices & Services → Devices, click your printer, and look for the G-code filename sensor.
Write down your entity IDs
# Fill in your serial number below — replace SERIAL with yours
print_status: sensor.p1s_SERIAL_print_status
active_tray:  sensor.p1s_SERIAL_active_tray
gcode_file:   sensor.p1s_SERIAL_gcode_file
remaining:    sensor.p1s_SERIAL_remaining_time
weight:       sensor.p1s_SERIAL_print_weight
progress:     sensor.p1s_SERIAL_print_progress
stage:        sensor.p1s_SERIAL_current_stage
5
Install File Editor

File Editor lets you edit HA configuration files directly in the browser — no FTP or SSH needed.

  1. Go to Settings → Add-ons → Add-on Store
  2. Search for File editor and install it
  3. Enable Show in sidebar so it's always accessible
  4. Click Start then Open Web UI
You'll see a file tree on the left and a code editor on the right.
6
YAMLEdit configuration.yaml — add REST commands

This file tells HA how to call the 3DPM API. We're adding 4 REST commands — one for each event (start, finish, pause, resume).

Open the file
  1. Open File Editor from the sidebar
  2. Click the folder icon (top left) → click configuration.yaml
Get your API key first
  1. Log into 3DPM
  2. Go to Settings → API
  3. Copy your API key — it looks like a long random string
YAML indentation is critical! Use exactly 2 spaces per indent level — never tabs. If you misalign anything, HA won't start. The word rest_command: must be at the very beginning of a line (zero spaces before it).
Add to the end of configuration.yaml

Replace YOUR_API_KEY with the key you copied from 3DPM:

rest_command:

  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('[]') }}
      }

  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) }}
      }

  3dpm_pause_print:
    url: "https://3dprintmanager.eu/api.php?key=YOUR_API_KEY&action=pause_print"
    method: POST
    headers:
      content_type: 'application/json'
    payload: >-
      {
        "printer_id": "{{ printer_id }}"
      }

  3dpm_resume_print:
    url: "https://3dprintmanager.eu/api.php?key=YOUR_API_KEY&action=resume_print"
    method: POST
    headers:
      content_type: 'application/json'
    payload: >-
      {
        "printer_id": "{{ printer_id }}",
        "slot": {{ slot | int(-1) }},
        "duration_minutes": {{ duration | int(0) }}
      }
Already have rest_command: in your file? Don't add a second one! Just paste the 5 commands inside the existing rest_command: block, keeping the same 2-space indent.
Save and validate
  1. Save the file (floppy icon)
  2. Go to Developer Tools → YAML → Check Configuration
  3. If it shows "Configuration valid!" → proceed
  4. Restart HA: Settings → System → Restart
7
AUTOMATIONSCreate 5 automations

Each automation watches for a specific printer event and calls the matching 3DPM REST command.

How to add each automation: Go to Settings → Automations & Scenes → Automations → click + Create Automation → click Edit in YAML (top right corner) → delete everything → paste the code below → Save.

In every automation, replace the highlighted parts:

  • sensor.p1s_SERIAL_* → your actual entity IDs from Step 4
  • YOUR_PRINTER_UUID → the Printer ID from 3DPM (Settings → Printers → Edit)

Automation 1 — Start Print

Fires when the printer starts. Sends job name, estimated duration, and filament weight to 3DPM.

alias: "3DPM: Start Print"
description: Reports new print job to 3DPM when P1S starts printing
triggers:
  - entity_id: sensor.p1s_SERIAL_print_status
    to: running
    trigger: state
conditions:
  - condition: template
    value_template: "{{ trigger.from_state.state != 'pause' }}"
actions:
  - wait_template: "{{ states('sensor.p1s_SERIAL_current_stage') | lower == 'printing' }}"
    timeout: "00:15:00"
    continue_on_timeout: false
  - delay: "00:00:05"
  - action: rest_command.3dpm_start_print
    data:
      printer_id: "YOUR_PRINTER_UUID"
      job_name: "{{ states('sensor.p1s_SERIAL_gcode_file').split('/')[-1] }}"
      duration: "{{ (states('sensor.p1s_SERIAL_remaining_time') | float(0) * 60) | round(0) }}"
      mapping: >-
        {% set tray_idx = state_attr('sensor.p1s_SERIAL_active_tray', 'tray_index') | int(-1) %}
        {% set slot = 0 if tray_idx in [254, -1] else tray_idx + 1 %}
        {% set weight_val = states('sensor.p1s_SERIAL_print_weight') | replace('g', '') | trim | float(0) | round(2) %}
        [{"slot": {{ slot }}, "weight": {{ weight_val }}}]
mode: single
The conditions block prevents this from firing when a print resumes from pause — the Resume automation handles that separately.

Automation 2 — Finish Print

Fires when a print finishes. The grams were already taken from the spools when the print started; this closes the job and logs the hours. A stopped or failed print goes through Automation 2b instead.

alias: "3DPM: Finish Print"
description: Closes the job in 3DPM when the print finishes (grams were deducted at start)
triggers:
  - entity_id: sensor.p1s_SERIAL_print_status
    to: finish
    trigger: state
actions:
  - action: rest_command.3dpm_finish_print
    data:
      printer_id: "YOUR_PRINTER_UUID"
      slot: >-
        {% set tray_idx = state_attr('sensor.p1s_SERIAL_active_tray', 'tray_index') | int(-1) %}
        {{ 0 if tray_idx in [254, -1] else tray_idx + 1 }}
      amount: >-
        {% set total_w = states('sensor.p1s_SERIAL_print_weight') | replace('g', '') | trim | float(0) %}
        {% set prog = states('sensor.p1s_SERIAL_print_progress') | float(100) %}
        {{ (total_w * (prog / 100)) | round(2) }}
      hours: 0
mode: single

Automation 2b — Failed or Cancelled Print

A print you stop on the printer, or one that fails, arrives as failed. 3DPM 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.p1s_SERIAL_print_status
    to: failed
    trigger: state
actions:
  - action: rest_command.3dpm_fail_print
    data:
      printer_id: "YOUR_PRINTER_UUID"
      progress: "{{ states('sensor.p1s_SERIAL_print_progress') | float(-1) }}"
mode: single

Automation 3 — Pause Print

Fires when the printer pauses (e.g. filament runout). Notifies 3DPM to pause the job.

alias: "3DPM: Pause Print"
description: Notifies 3DPM that the print is paused
triggers:
  - entity_id: sensor.p1s_SERIAL_print_status
    to: pause
    trigger: state
actions:
  - action: rest_command.3dpm_pause_print
    data:
      printer_id: "YOUR_PRINTER_UUID"
mode: single

Automation 4 — Resume Print

Fires when print resumes from pause. Waits for AMS tray to be ready, then updates remaining time in 3DPM.

alias: "3DPM: Resume Print"
description: Notifies 3DPM that print has resumed, with updated remaining time
triggers:
  - entity_id: sensor.p1s_SERIAL_print_status
    from: pause
    to: running
    trigger: state
actions:
  - wait_template: "{{ state_attr('sensor.p1s_SERIAL_active_tray', 'tray_index') | int(-1) >= 0 }}"
    timeout: "00:05:00"
    continue_on_timeout: true
  - delay: "00:00:05"
  - action: rest_command.3dpm_resume_print
    data:
      printer_id: "YOUR_PRINTER_UUID"
      slot: >-
        {% set tray_idx = state_attr('sensor.p1s_SERIAL_active_tray', 'tray_index') | int(-1) %}
        {{ 0 if tray_idx in [254, -1] else tray_idx + 1 }}
      duration: "{{ (states('sensor.p1s_SERIAL_remaining_time') | float(0) * 60) | round(0) }}"
mode: single
8
Test everything
Quick test — call the API manually
  1. Go to Developer Tools → Services
  2. In the Service field type: rest_command.3dpm_start_print
  3. In Service data paste:
printer_id: "YOUR_PRINTER_UUID"
job_name: "test_api_call"
duration: "30"
mapping: '[{"slot": 1, "weight": 5}]'
  1. Click Call Service
  2. Open 3DPM → check the scheduler — you should see a test job appear ✅
Real print test
  1. Start a print on your P1S from Bambu Studio or the Handy app
  2. In HA go to Settings → Automations → 3DPM: Start Print → Traces
  3. You should see a green trace entry — that means it fired ✅
  4. Check 3DPM — the print should be visible in the scheduler ✅
  5. When the print finishes, verify the filament weight decreased on the spool ✅
Everything working? Your printer is now fully connected. Every print automatically tracks filament usage in 3DPM.

Common issues
ProblemFix
REST command returns errorDouble-check your API key in configuration.yaml — no extra spaces
Automation doesn't fireCheck entity ID in Developer Tools → States. Make sure print_status actually changes value when printing
HA won't start after editingYAML indentation error. Run Configuration Check, look for the error line
Grams not deductedCheck Finish Print automation Traces — did it run? Is the printer_id correct?
🖨️ + 🏠 + 📊

Bambu Lab i Home Assistant: postavljanje za P1S, X1C, A1

Kompletni vodič za automatsko praćenje filamenta

Korak po korak — ne treba prethodno iskustvo s Home Assistantom

Bez Home Assistanta: 3DPM Agent

Bez Home Assistant servera i bez MQTT postavki. 3DPM Agent za Windows (Microsoft Store) knjiži printove s Bambu Lab, Prusa (PrusaLink) i Klipper (Moonraker) printera u 3D Print Manager i skida grame s pravih rola kad print krene; zaustavljeni ili neuspjeli print dobiva neisprintani dio natrag. Uključen je u PRO i FARM. Registrirajte se iz ovog vodiča i PRO je 30 dana besplatan, bez kartice. Postavljanje: poglavlje 7b korisničkog priručnika.

Ovaj vodič je za printere koje već vodite kroz Home Assistant i za ostale marke.

Pregled

Kako funkcionira veza 3DPM + HA?

Prije nego počnemo klikati, vrijedi razumjeti što zapravo gradimo — da nam ništa ne izgleda kao magija.

Velika slika

Tvoj Bambu P1S je na Wi-Fi mreži. Home Assistant (HA) se spaja na njega i čita status u realnom vremenu — stvari poput "tiska li trenutno?", "koliko grama filamenta koristi ovaj print?", "koliko minuta je ostalo?".

Kada se status printera promijeni (npr. s idle na running), HA pokreće automatizaciju. Ta automatizacija poziva 3DPM API — praktički šalje poruku "hej, printer upravo je počeo 90-minutni print koji troši 45g filamenta iz slota 1". 3DPM to prima, kreira zapis o printu i skida filament iz inventara — sve automatski.

Tok podataka korak po korak


P1S
počinje printati
→

Home Assistant
detektira promjenu
→

Automatizacija
čita podatke senzora
→

3DPM API
bilježi i skida grame

5 događaja koja pratimo

Start Print

Aktivira se kad status prijeđe na running. HA pričeka nekoliko sekundi da printer uđe u fazu printanja, zatim čita naziv fajla, procijenjeno trajanje i težinu filamenta — i sve to šalje 3DPM-u, koji odmah skida grame s mapiranih rola.

Finish Print

Aktivira se kad print završi (finish) i zatvara posao. Grami su skinuti s rola već na startu, pa se ovdje ništa više ne skida.

Neuspjeli ili otkazani print

Aktivira se kad se print zaustavi ili ne uspije (failed). 3DPM zatvara posao kao neuspio i vraća na rolu grame koji nisu isprintani, prema zadnjem napretku koji je printer javio.

Pause Print

Aktivira se kad status prijeđe na pause. Obavještava 3DPM da je print pauziran. Ovo je važno za detekciju nestanka filamenta — 3DPM će označiti job za zamjenu role.

Resume Print

Aktivira se kad status prijeđe iz pause natrag na running. HA čeka da AMS tray bude spreman, zatim šalje novo preostalo vrijeme 3DPM-u da se timeline schedulera ispravno ažurira.

Što je API ključ?

API ključ je tvoja osobna lozinka za 3DPM API. Dokazuje 3DPM-u da zahtjev dolazi s tvog Home Assistanta — a ne od nekog drugog. Naći ćeš ga u 3DPM pod Settings → API. Izgleda kao dugački niz slučajnih znakova, npr. a8058e74d9d8ec984dd29293...

Što je Printer ID?

Svaki printer koji dodaš u 3DPM dobiva jedinstveni UUID — dugi ID koji izgleda poput b7b71ff0-1a91-11f1-b989-566fc143004c. To govori API-ju koji printer printa. Naći ćeš ga u 3DPM pod Settings → Printers → Edit.

Na printeru se ništa ne instalira. P1S ne treba nikakvu izmjenu firmwarea. HA čita podatke kroz Bambu Cloud ili direktnu lokalnu konekciju — isti način kao službena Bambu Handy aplikacija. 3DPM samo čita te podatke — nikada ne upravlja printerom: ne pokreće, ne zaustavlja, ne pauzira niti šalje poslove. Vaš slicer i printerove aplikacije ostaju zaduženi za printanje.
Prije početka

Što ti treba

  • Pokrenut Home Assistant (bilo koji tip instalacije)
  • Bambu P1S na Wi-Fi mreži
  • Bambu račun (email + lozinka)
  • 3DPM račun (PRO ili FARM plan)
  • Printer dodan u 3DPM pod Settings → Printers
  • ~30 minuta slobodnog vremena
1
HACSInstaliraj HACS

HACS je community app store za HA. Bez njega ne možeš instalirati Bambu Lab integraciju.

Instaliraj Terminal add-on
  1. Idi na Settings → Add-ons → Add-on Store
  2. Traži Terminal & SSH i instaliraj
  3. Klikni Start pa Open Web UI
Pokreni HACS installer
  1. U terminal prozoru zalijepi ovu naredbu i pritisni Enter:
wget -O - https://get.hacs.xyz | bash -
  1. Pričekaj zelene poruke — gotovo kad vidiš HACS is now installed
  2. Restart HA: Settings → System → Restart
Aktiviraj HACS
  1. Idi na Settings → Devices & Services → Add Integration
  2. Traži HACS i klikni
  3. Prihvati uvjete i poveži GitHub račun (treba besplatni GitHub račun)
Gotovo kad: U lijevom izborniku se pojavi stavka HACS.
2
HACSInstaliraj Bambu Lab integraciju
  1. Klikni HACS u izborniku
  2. Klikni Integrations tab
  3. Klikni + Explore & Download Repositories
  4. Traži: Bambu Lab
  5. Odaberi Bambu Lab od autora greghesp
  6. Klikni Download → potvrdi
  7. Restart HA
Provjeri autora! Ispravna integracija je od greghesp. Postoje kopije — uzmi pravu.
3
Poveži P1S s Home Assistantom
  1. Idi na Settings → Devices & Services → Add Integration
  2. Traži Bambu Lab i klikni
  3. Bira se način spajanja: Cloud (upiši email i lozinku Bambu računa) ili Local (upiši IP adresu i Access Code printera)
  4. Preporučujemo Cloud za početnike — samo email i lozinka pa gotovo
  5. Unesi podatke i klikni Submit
Gotovo kad: Pod Devices & Services se pojavi kartica s imenom tvog printera.
4
Pronađi entity ID-ove P1S printera

Svaki senzor ima jedinstveni ID oblika: sensor.p1s_SERIJSKIBROJ_naziv_senzora

Kako pronaći
  1. Idi na Developer Tools → States
  2. U filter upiši p1s
  3. Vidiš sve senzore svog P1S printera s njihovim entity ID-ovima
SenzorZavršava s
Status printa_print_status
Aktivni AMS tray_active_tray
Naziv G-code fajla_gcode_file
Preostalo vrijeme_remaining_time
Težina filamenta_print_weight
Napredak (%)_print_progress
Trenutna faza_current_stage
Razlika u nazivu senzora: Sufiks G-code senzora nije isti za sve modele. P1S koristi _gcode_file. P2S i A1 koriste _gcode_filename. Za ostale modele provjeri pravi entity ID direktno u Home Assistantu: idi na Settings → Devices & Services → Devices, klikni svoj printer i potraži senzor naziva G-code datoteke.
5
Instaliraj File Editor
  1. Idi na Settings → Add-ons → Add-on Store
  2. Traži File editor i instaliraj
  3. Uključi Show in sidebar
  4. Klikni Start pa Open Web UI
Vidjet ćeš stablo fajlova i uređivač koda.
6
YAMLUredi configuration.yaml

Ovaj fajl govori HA-u kako zvati 3DPM API. Dodajemo 4 REST komande.

API ključ
  1. U 3DPM idi na Settings → API
  2. Kopiraj API ključ
Otvori fajl
  1. U File Editoru klikni ikonu foldera → klikni configuration.yaml
Indentacija je kritična! Koristi točno 2 razmaka po razini, nikad Tab. Riječ rest_command: mora biti na samom početku retka (nula razmaka ispred).
Dodaj na kraj fajla

Zamijeni TVOJ_API_KLJUČ s ključem iz 3DPM:

rest_command:

  3dpm_start_print:
    url: "https://3dprintmanager.eu/api.php?key=TVOJ_API_KLJUČ&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('[]') }}
      }

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

  3dpm_pause_print:
    url: "https://3dprintmanager.eu/api.php?key=TVOJ_API_KLJUČ&action=pause_print"
    method: POST
    headers:
      content_type: 'application/json'
    payload: >-
      {
        "printer_id": "{{ printer_id }}"
      }

  3dpm_resume_print:
    url: "https://3dprintmanager.eu/api.php?key=TVOJ_API_KLJUČ&action=resume_print"
    method: POST
    headers:
      content_type: 'application/json'
    payload: >-
      {
        "printer_id": "{{ printer_id }}",
        "slot": {{ slot | int(-1) }},
        "duration_minutes": {{ duration | int(0) }}
      }
Spremi i provjeri
  1. Spremi fajl
  2. Idi na Developer Tools → YAML → Check Configuration
  3. Ako piše "Configuration valid!" — restart HA
Već imaš rest_command: u fajlu? Ne dodavaj novi! Samo dodaj 5 komandi unutar postojećeg bloka s istim uvlakom.
7
AUTOMATIONSKreiraj 5 automatizacija
Kako dodati: Settings → Automations → + Create Automation → klikni Edit in YAML (gore desno) → izbriši sve → zalijepi kod → Spremi.

U svakoj automatizaciji zamijeni sensor.p1s_SERIAL_* s tvojim entity ID-ovima iz Koraka 4, i UUID_PRINTERA s Printer ID-om iz 3DPM.


Automatizacija 1 — Start Print

alias: "3DPM: Start Print"
description: Prijavljuje novi print 3DPM-u kad P1S počne printati
triggers:
  - entity_id: sensor.p1s_SERIAL_print_status
    to: running
    trigger: state
conditions:
  - condition: template
    value_template: "{{ trigger.from_state.state != 'pause' }}"
actions:
  - wait_template: "{{ states('sensor.p1s_SERIAL_current_stage') | lower == 'printing' }}"
    timeout: "00:15:00"
    continue_on_timeout: false
  - delay: "00:00:05"
  - action: rest_command.3dpm_start_print
    data:
      printer_id: "UUID_PRINTERA"
      job_name: "{{ states('sensor.p1s_SERIAL_gcode_file').split('/')[-1] }}"
      duration: "{{ (states('sensor.p1s_SERIAL_remaining_time') | float(0) * 60) | round(0) }}"
      mapping: >-
        {% set tray_idx = state_attr('sensor.p1s_SERIAL_active_tray', 'tray_index') | int(-1) %}
        {% set slot = 0 if tray_idx in [254, -1] else tray_idx + 1 %}
        {% set weight_val = states('sensor.p1s_SERIAL_print_weight') | replace('g', '') | trim | float(0) | round(2) %}
        [{"slot": {{ slot }}, "weight": {{ weight_val }}}]
mode: single

Automatizacija 2 — Finish Print

alias: "3DPM: Finish Print"
description: Zatvara posao u 3DPM-u kad print završi (grami su skinuti na startu)
triggers:
  - entity_id: sensor.p1s_SERIAL_print_status
    to: finish
    trigger: state
actions:
  - action: rest_command.3dpm_finish_print
    data:
      printer_id: "UUID_PRINTERA"
      slot: >-
        {% set tray_idx = state_attr('sensor.p1s_SERIAL_active_tray', 'tray_index') | int(-1) %}
        {{ 0 if tray_idx in [254, -1] else tray_idx + 1 }}
      amount: >-
        {% set total_w = states('sensor.p1s_SERIAL_print_weight') | replace('g', '') | trim | float(0) %}
        {% set prog = states('sensor.p1s_SERIAL_print_progress') | float(100) %}
        {{ (total_w * (prog / 100)) | round(2) }}
      hours: 0
mode: single

Automatizacija 2b — Neuspjeli ili otkazani print

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

alias: "3DPM: Failed or Cancelled Print"
description: Vraća neisprintani filament na rolu kad je print otkazan ili neuspio
triggers:
  - entity_id: sensor.p1s_SERIAL_print_status
    to: failed
    trigger: state
actions:
  - action: rest_command.3dpm_fail_print
    data:
      printer_id: "UUID_PRINTERA"
      progress: "{{ states('sensor.p1s_SERIAL_print_progress') | float(-1) }}"
mode: single

Automatizacija 3 — Pause Print

alias: "3DPM: Pause Print"
description: Javlja 3DPM-u da je print pauziran
triggers:
  - entity_id: sensor.p1s_SERIAL_print_status
    to: pause
    trigger: state
actions:
  - action: rest_command.3dpm_pause_print
    data:
      printer_id: "UUID_PRINTERA"
mode: single

Automatizacija 4 — Resume Print

alias: "3DPM: Resume Print"
description: Javlja 3DPM-u da se print nastavlja s novim preostalim vremenom
triggers:
  - entity_id: sensor.p1s_SERIAL_print_status
    from: pause
    to: running
    trigger: state
actions:
  - wait_template: "{{ state_attr('sensor.p1s_SERIAL_active_tray', 'tray_index') | int(-1) >= 0 }}"
    timeout: "00:05:00"
    continue_on_timeout: true
  - delay: "00:00:05"
  - action: rest_command.3dpm_resume_print
    data:
      printer_id: "UUID_PRINTERA"
      slot: >-
        {% set tray_idx = state_attr('sensor.p1s_SERIAL_active_tray', 'tray_index') | int(-1) %}
        {{ 0 if tray_idx in [254, -1] else tray_idx + 1 }}
      duration: "{{ (states('sensor.p1s_SERIAL_remaining_time') | float(0) * 60) | round(0) }}"
mode: single
8
Testiranje
Brzi test — pozovi API ručno
  1. Idi na Developer Tools → Services
  2. Service: rest_command.3dpm_start_print
  3. Service data:
printer_id: "UUID_PRINTERA"
job_name: "test_poziv"
duration: "30"
mapping: '[{"slot": 1, "weight": 5}]'
  1. Klikni Call Service → provjeri u 3DPM je li se pojavio testni job ✅
Pravi test
  1. Pokreni print na P1S normalno (iz Bambu Studio ili Handy app)
  2. U HA provjeri: Automations → 3DPM: Start Print → Traces — vidiš li zeleni trace? ✅
  3. U 3DPM je li vidljiv print u scheduleru? ✅
  4. Kad print završi — je li se gramaza role smanjila? ✅
Sve radi? Čestitamo! Od sad svaki print automatski ažurira stanje filamenta.

Česti problemi
ProblemRješenje
REST komanda vraća greškuProvjeri API ključ — bez razmaka
Automatizacija se ne pokrećeProvjeri entity ID u Developer Tools → States
HA ne starta nakon editaGreška u YAML indentaciji — pokreni Configuration Check
Grami se ne odbijajuProvjeri Finish Print Traces i Printer ID
🖨️ + 🏠 + 📊

Bambu Lab mit Home Assistant: Einrichtung für P1S, X1C, A1

Vollständige Anleitung für automatisches Filament-Tracking

Schritt für Schritt — keine Vorkenntnisse mit Home Assistant erforderlich

Ohne Home Assistant: 3DPM Agent

Kein Home-Assistant-Server und keine MQTT-Einrichtung. 3DPM Agent für Windows (Microsoft Store) bucht Drucke von Bambu-Lab-, Prusa- (PrusaLink) und Klipper-Druckern (Moonraker) in 3D Print Manager und zieht die Gramm beim Druckstart von den richtigen Rollen ab; ein gestoppter oder fehlgeschlagener Druck bekommt den nicht gedruckten Teil zurück. Er ist in PRO und FARM enthalten. Registrieren Sie sich über diese Anleitung und PRO ist 30 Tage kostenlos, ohne Karte. Einrichtung: Kapitel 7b des Benutzerhandbuchs.

Diese Anleitung ist für Drucker, die Sie bereits über Home Assistant betreiben, und für andere Marken.

Überblick

Wie funktioniert die 3DPM + HA Verbindung?

Bevor wir anfangen zu klicken, lohnt es sich zu verstehen, was wir eigentlich aufbauen.

Das große Bild

Dein Bambu P1S ist im WLAN. Home Assistant (HA) verbindet sich damit und liest den Status in Echtzeit — Dinge wie "druckt es gerade?", "wie viele Gramm Filament verbraucht dieser Druck?", "wie viele Minuten sind noch übrig?".

Wenn sich der Status des Druckers ändert (z.B. von Leerlauf auf Drucken), löst HA eine Automatisierung aus. Diese Automatisierung ruft die 3DPM API auf — sendet eine Nachricht wie "Hey, der Drucker hat gerade einen 90-minütigen Druck mit 45g Filament aus Slot 1 gestartet". 3DPM empfängt das, erstellt einen Druckauftrag und zieht das Filament vom Inventar ab — vollautomatisch.

Datenfluss Schritt für Schritt


P1S
startet Druck
→

Home Assistant
erkennt Statusänderung
→

Automatisierung
liest Sensordaten
→

3DPM API
speichert & zieht ab

Die 5 Ereignisse, die wir verfolgen

Druck starten

Ausgelöst wenn Status auf running wechselt. HA wartet kurz, liest Dateiname, geschätzte Dauer und Filamentgewicht — und sendet alles an 3DPM, das die Gramm sofort von den zugeordneten Rollen abzieht.

Druck beenden

Ausgelöst, wenn der Druck fertig ist (finish), und schließt den Auftrag ab. Die Gramm wurden schon beim Start abgezogen, hier wird nichts mehr abgebucht.

Fehlgeschlagener oder abgebrochener Druck

Ausgelöst, wenn ein Druck gestoppt wird oder fehlschlägt (failed). 3DPM schließt den Auftrag als fehlgeschlagen und bucht die nicht gedruckten Gramm nach dem zuletzt gemeldeten Fortschritt zurück.

Druck pausieren

Ausgelöst wenn Status auf pause wechselt. Benachrichtigt 3DPM dass der Auftrag pausiert ist — wichtig für Filament-Runout-Erkennung.

Druck fortsetzen

Ausgelöst wenn Status von pause zurück auf running wechselt. Sendet neue verbleibende Zeit an 3DPM damit der Zeitplan korrekt aktualisiert wird.

Was ist der API-Schlüssel?

Der API-Schlüssel ist dein persönliches Passwort für die 3DPM API. Du findest ihn in 3DPM unter Settings → API. Er sieht aus wie ein langer zufälliger String, z.B. a8058e74d9d8ec984dd29293...

Was ist die Drucker-ID?

Jeder in 3DPM hinzugefügte Drucker bekommt eine eindeutige UUID — eine lange ID wie b7b71ff0-1a91-11f1-b989-566fc143004c. Du findest sie in 3DPM unter Settings → Printers → Edit.

Am Drucker wird nichts installiert. Der P1S benötigt keine Firmware-Änderung. HA liest Daten über die Bambu Cloud oder direkte lokale Verbindung — genauso wie die offizielle Bambu Handy App. 3DPM liest diese Daten nur — es steuert Ihren Drucker nie: es startet, stoppt, pausiert oder sendet keine Druckaufträge. Ihr Slicer und die Drucker-Apps bleiben für das Drucken zuständig.
Voraussetzungen

Was du brauchst

  • Home Assistant läuft (beliebiger Installationstyp)
  • Bambu P1S im WLAN
  • Bambu-Konto (E-Mail + Passwort)
  • 3DPM-Konto (PRO oder FARM-Plan)
  • Drucker in 3DPM unter Settings → Printers hinzugefügt
  • ~30 Minuten Zeit
1
HACSHACS installieren
  1. Gehe zu Settings → Add-ons → Add-on Store
  2. Suche Terminal & SSH und installiere es
  3. Klicke Start dann Open Web UI
  4. Im Terminal-Fenster diesen Befehl eingeben und Enter drücken:
wget -O - https://get.hacs.xyz | bash -
  1. Warte auf grüne Ausgabe — fertig wenn HACS is now installed erscheint
  2. HA neu starten: Settings → System → Restart
  3. Gehe zu Settings → Devices & Services → Add Integration
  4. Suche HACS, akzeptiere die Bedingungen, verknüpfe GitHub-Konto
Fertig wenn: HACS in der linken Seitenleiste erscheint.
2
HACSBambu Lab Integration installieren
  1. Klicke HACS in der Seitenleiste → Tab Integrations
  2. Klicke + Explore & Download Repositories
  3. Suche: Bambu Lab → wähle Bambu Lab von greghesp
  4. Klicke Download → bestätigen → HA neu starten
Autor prüfen! Die richtige Integration ist von greghesp.
3
P1S mit Home Assistant verbinden
  1. Gehe zu Settings → Devices & Services → Add Integration
  2. Suche Bambu Lab und klicke darauf
  3. Wähle Cloud (empfohlen für Anfänger — E-Mail + Passwort des Bambu-Kontos eingeben) oder Local (IP-Adresse + Access Code des Druckers)
  4. Daten eingeben und Submit klicken
Fertig wenn: Eine Karte mit dem Druckernamen unter Devices & Services erscheint.
4
Entity-IDs des P1S herausfinden

Jeder Sensor hat eine eindeutige ID nach dem Muster: sensor.p1s_SERIENNUMMER_sensor_name

  1. Gehe zu Developer Tools → States
  2. Im Filter-Feld p1s eingeben
  3. Alle P1S-Sensoren mit ihren Entity-IDs werden angezeigt
SensorEntity-ID endet mit
Druckstatus_print_status
Aktives AMS-Fach_active_tray
G-Code Dateiname_gcode_file
Verbleibende Zeit_remaining_time
Filamentgewicht_print_weight
Druckfortschritt (%)_print_progress
Aktuelle Phase_current_stage
Unterschied im Sensornamen: Das Suffix des G-Code-Sensors ist nicht bei allen Modellen gleich. P1S verwendet _gcode_file. P2S und A1 verwenden _gcode_filename. Bei anderen Modellen prüfe die tatsächliche Entity-ID direkt in Home Assistant: Settings → Devices & Services → Devices → Drucker anklicken → nach dem G-Code-Dateinamen-Sensor suchen.
5
File Editor installieren
  1. Gehe zu Settings → Add-ons → Add-on Store
  2. Suche File editor → installieren
  3. Show in sidebar aktivieren → Start → Open Web UI
6
YAMLconfiguration.yaml bearbeiten
  1. API-Schlüssel in 3DPM kopieren: Settings → API
  2. Im File Editor configuration.yaml öffnen
Einrückung ist entscheidend! Genau 2 Leerzeichen pro Ebene — nie Tabs. rest_command: muss am Zeilenanfang stehen (null Leerzeichen davor).

Ans Ende der Datei anfügen — DEIN_API_SCHLÜSSEL ersetzen:

rest_command:

  3dpm_start_print:
    url: "https://3dprintmanager.eu/api.php?key=DEIN_API_SCHLÜSSEL&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('[]') }}
      }

  3dpm_finish_print:
    url: "https://3dprintmanager.eu/api.php?key=DEIN_API_SCHLÜSSEL&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=DEIN_API_SCHLÜSSEL&action=fail_print"
    method: POST
    headers:
      content_type: 'application/json'
    payload: >-
      {
        "printer_id": "{{ printer_id }}",
        "progress": {{ progress | float(-1) }}
      }

  3dpm_pause_print:
    url: "https://3dprintmanager.eu/api.php?key=DEIN_API_SCHLÜSSEL&action=pause_print"
    method: POST
    headers:
      content_type: 'application/json'
    payload: >-
      {
        "printer_id": "{{ printer_id }}"
      }

  3dpm_resume_print:
    url: "https://3dprintmanager.eu/api.php?key=DEIN_API_SCHLÜSSEL&action=resume_print"
    method: POST
    headers:
      content_type: 'application/json'
    payload: >-
      {
        "printer_id": "{{ printer_id }}",
        "slot": {{ slot | int(-1) }},
        "duration_minutes": {{ duration | int(0) }}
      }
  1. Datei speichern → Developer Tools → YAML → Check Configuration
  2. Bei "Configuration valid!" → HA neu starten
7
AUTOMATIONS5 Automatisierungen erstellen
So hinzufügen: Settings → Automations → + Create Automation → Edit in YAML (oben rechts) → alles löschen → Code einfügen → Speichern.

sensor.p1s_SERIAL_* durch deine Entity-IDs ersetzen, UUID_DRUCKER durch die Drucker-ID aus 3DPM.


Automatisierung 1 — Druck starten

alias: "3DPM: Start Print"
description: Meldet neuen Druckauftrag an 3DPM wenn P1S zu drucken beginnt
triggers:
  - entity_id: sensor.p1s_SERIAL_print_status
    to: running
    trigger: state
conditions:
  - condition: template
    value_template: "{{ trigger.from_state.state != 'pause' }}"
actions:
  - wait_template: "{{ states('sensor.p1s_SERIAL_current_stage') | lower == 'printing' }}"
    timeout: "00:15:00"
    continue_on_timeout: false
  - delay: "00:00:05"
  - action: rest_command.3dpm_start_print
    data:
      printer_id: "UUID_DRUCKER"
      job_name: "{{ states('sensor.p1s_SERIAL_gcode_file').split('/')[-1] }}"
      duration: "{{ (states('sensor.p1s_SERIAL_remaining_time') | float(0) * 60) | round(0) }}"
      mapping: >-
        {% set tray_idx = state_attr('sensor.p1s_SERIAL_active_tray', 'tray_index') | int(-1) %}
        {% set slot = 0 if tray_idx in [254, -1] else tray_idx + 1 %}
        {% set weight_val = states('sensor.p1s_SERIAL_print_weight') | replace('g', '') | trim | float(0) | round(2) %}
        [{"slot": {{ slot }}, "weight": {{ weight_val }}}]
mode: single

Automatisierung 2 — Druck beenden

alias: "3DPM: Finish Print"
description: Schließt den Auftrag in 3DPM ab, wenn der Druck endet (Gramm wurden beim Start abgezogen)
triggers:
  - entity_id: sensor.p1s_SERIAL_print_status
    to: finish
    trigger: state
actions:
  - action: rest_command.3dpm_finish_print
    data:
      printer_id: "UUID_DRUCKER"
      slot: >-
        {% set tray_idx = state_attr('sensor.p1s_SERIAL_active_tray', 'tray_index') | int(-1) %}
        {{ 0 if tray_idx in [254, -1] else tray_idx + 1 }}
      amount: >-
        {% set total_w = states('sensor.p1s_SERIAL_print_weight') | replace('g', '') | trim | float(0) %}
        {% set prog = states('sensor.p1s_SERIAL_print_progress') | float(100) %}
        {{ (total_w * (prog / 100)) | round(2) }}
      hours: 0
mode: single

Automatisierung 2b — Fehlgeschlagener oder abgebrochener Druck

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

alias: "3DPM: Failed or Cancelled Print"
description: Bucht nicht gedrucktes Filament zurück, wenn ein Druck abgebrochen wird oder fehlschlägt
triggers:
  - entity_id: sensor.p1s_SERIAL_print_status
    to: failed
    trigger: state
actions:
  - action: rest_command.3dpm_fail_print
    data:
      printer_id: "UUID_DRUCKER"
      progress: "{{ states('sensor.p1s_SERIAL_print_progress') | float(-1) }}"
mode: single

Automatisierung 3 — Druck pausieren

alias: "3DPM: Pause Print"
description: Benachrichtigt 3DPM dass der Druck pausiert ist
triggers:
  - entity_id: sensor.p1s_SERIAL_print_status
    to: pause
    trigger: state
actions:
  - action: rest_command.3dpm_pause_print
    data:
      printer_id: "UUID_DRUCKER"
mode: single

Automatisierung 4 — Druck fortsetzen

alias: "3DPM: Resume Print"
description: Benachrichtigt 3DPM dass der Druck mit aktualisierter verbleibender Zeit fortgesetzt wird
triggers:
  - entity_id: sensor.p1s_SERIAL_print_status
    from: pause
    to: running
    trigger: state
actions:
  - wait_template: "{{ state_attr('sensor.p1s_SERIAL_active_tray', 'tray_index') | int(-1) >= 0 }}"
    timeout: "00:05:00"
    continue_on_timeout: true
  - delay: "00:00:05"
  - action: rest_command.3dpm_resume_print
    data:
      printer_id: "UUID_DRUCKER"
      slot: >-
        {% set tray_idx = state_attr('sensor.p1s_SERIAL_active_tray', 'tray_index') | int(-1) %}
        {{ 0 if tray_idx in [254, -1] else tray_idx + 1 }}
      duration: "{{ (states('sensor.p1s_SERIAL_remaining_time') | float(0) * 60) | round(0) }}"
mode: single
8
Testen
Schnelltest — API manuell aufrufen
  1. Gehe zu Developer Tools → Services
  2. Service: rest_command.3dpm_start_print
  3. Service data:
printer_id: "UUID_DRUCKER"
job_name: "api_test"
duration: "30"
mapping: '[{"slot": 1, "weight": 5}]'
  1. Klicke Call Service → in 3DPM prüfen ob ein Testauftrag erscheint ✅
Alles funktioniert? Ab jetzt wird jeder Druck automatisch im 3DPM verfolgt.

Häufige Probleme
ProblemLösung
REST-Befehl gibt Fehler zurückAPI-Schlüssel in configuration.yaml prüfen — keine Leerzeichen
Automatisierung löst nicht ausEntity-ID in Developer Tools → States prüfen
HA startet nicht nach BearbeitungYAML-Einrückungsfehler — Configuration Check ausführen
Gramm werden nicht abgezogenFinish Print Traces prüfen — ist die Drucker-ID korrekt?

3D Print Manager — Home Assistant Integration Guide

3dprintmanager.eu