TL;DR: With Moonraker's job queue and power component, you can queue print jobs and your 3D printer will automatically power on, preheat, and start printing. No more manual power-on required!

🤔 The Problem: Manually Powering On Your Printer Is Annoying

Sound familiar? You prepare your print in the slicer, export the G-Code, upload it — and then you have to walk over to the printer, switch it on, and wait until it's ready. Wouldn't it be great if you could simply queue a print job and the printer powers on automatically?

That's exactly what Moonraker enables with its job queue and power component. In this article, I'll show you how to set it up.

📋 Prerequisites

  • Klipper as firmware on your 3D printer
  • Moonraker as the API server (included with MainsailOS or FluiddPi, for example)
  • A smart plug (Tasmota, Shelly, TP-Link, etc.) or a controllable relay
  • Network access between Moonraker and the smart plug

🔌 Moonraker: Configure the Power Component

First, you need to teach Moonraker how to turn your printer on and off. This is done via the [power] section in moonraker.conf:

# moonraker.conf

[power printer]
type: tasmota
address: 192.168.1.100
# Alternative for Shelly:
# type: shelly
# address: 192.168.1.101

# Don't turn off the printer during a print
locked_while_printing: True

# Wait briefly after powering on
restart_klipper_when_powered: True
restart_delay: 3

# Automatically power on when a print is started
bound_services: klipper

Here's an overview of the key parameters:

  • type: The type of your smart plug (tasmota, shelly, tplink_smartplug, homeassistant, http, etc.)
  • address: IP address of the smart plug
  • locked_while_printing: Prevents accidental power-off during a print
  • restart_klipper_when_powered: Automatically restarts the Klipper service after powering on
  • bound_services: Binds the power state to Klipper
Switch on 3D printer when slicer is opened
Learn how to automatically power on your 3D printer when you open your slicer.

📥 Configure the Job Queue

Now comes the core piece: the job queue. It allows you to queue print jobs that will be processed automatically — even if the printer is currently off.

# moonraker.conf

[job_queue]
load_on_startup: True
automatic_transition: True

With load_on_startup: True, the queue is loaded when Moonraker starts. automatic_transition: True ensures that the next job starts automatically after a print completes.

⚙️ Klipper Macro: Wait for Readiness

When the printer powers on, it needs a moment to boot up. With a delayed_gcode macro in printer.cfg, you ensure everything is ready before the print starts:

# printer.cfg

[delayed_gcode POWER_ON_WAIT]
initial_duration: 0
gcode:
    {% if printer.idle_timeout.state == "Idle" %}
        # Printer is booted and ready
        M117 Printer ready - starting print
        RESPOND MSG="Printer is booted and ready"
    {% else %}
        # Not ready yet, check again
        UPDATE_DELAYED_GCODE ID=POWER_ON_WAIT DURATION=5
    {% endif %}

[gcode_macro POWER_ON_PRINTER]
gcode:
    # Wait until Klipper is connected
    UPDATE_DELAYED_GCODE ID=POWER_ON_WAIT DURATION=10
    M117 Waiting for printer to start...

This macro checks every 5 seconds whether the printer is in the Idle state, meaning it's ready for a new print.

🔄 The Workflow: From Upload to Finished Print

Here's the complete process:

  1. Upload G-Code: Upload your G-Code via Mainsail, Fluidd, or the API
  2. Add job to queue: Add the print to the job queue
  3. Printer powers on: Moonraker detects the new job and powers on the printer via the power component
  4. Klipper starts: The Klipper service connects to the printer
  5. Print starts automatically: Once Klipper is ready, the first job from the queue is started
  6. Next job: After completion, the next job starts automatically (if available)

🌐 Moonraker API: Control Jobs via API

You can also control the job queue entirely through the Moonraker API. This is especially useful for automations:

# Upload file
curl -X POST "http://<moonraker-ip>:7125/server/files/upload" \
  -F "file=@my_print.gcode"

# Add job to queue
curl -X POST "http://<moonraker-ip>:7125/server/job_queue/job" \
  -H "Content-Type: application/json" \
  -d '{"filenames": ["my_print.gcode"]}'

# Start the queue
curl -X POST "http://<moonraker-ip>:7125/server/job_queue/start"

# Check queue status
curl "http://<moonraker-ip>:7125/server/job_queue/status"

# Remove a job from the queue
curl -X DELETE "http://<moonraker-ip>:7125/server/job_queue/job?job_ids=JOB_ID"

🏠 Integration with Home Assistant (Optional)

If you use Home Assistant, you can leverage the Moonraker integration to further automate the workflow. For example:

  • Notifications: Push notification to your phone when a print is finished
  • Automations: Automatically power off the printer after X minutes of idle time
  • Dashboard: Print status and queue overview in your Home Assistant dashboard
  • Scenes: Activate "print mode" — lights on, camera on, printer on

The Moonraker integration for Home Assistant is available as a HACS integration under the name Moonraker. Alternatively, you can configure the power component directly as type: homeassistant if your smart plug is already integrated in Home Assistant:

# moonraker.conf - Home Assistant as Power Device

[power printer]
type: homeassistant
address: 192.168.1.50
port: 8123
device: switch.3d_printer
token: YOUR_LONG_LIVED_ACCESS_TOKEN
domain: switch
Automate Home Assistant with WebHooks
Learn how to automate Home Assistant with WebHooks.

🎯 Conclusion

By combining Moonraker's job queue and power component, your 3D printing workflow becomes significantly more convenient. Simply upload your G-Code files, add them to the queue — and everything else happens automatically. This is particularly handy when you want to run multiple prints in succession or operate the printer remotely.

Setup takes just a few minutes and works with virtually any smart plug supported by Moonraker.

Artikel teilen:Share article: