Frequently Asked Questions
Why did my 3D printer keep pausing unexpectedly?
Your 3D printer might be pausing unexpectedly due to an enabled filament runout detection feature in its firmware. If you don’t have a physical sensor, the printer can misinterpret this lack of connection as a runout, causing unwanted pauses. Disabling this feature via a G-code command like M412 S0 in OctoPrint usually resolves this issue.
How can I stop Home Assistant from turning off my 3D printer when it’s just paused?
The ‘octoprint_printing’ binary sensor in Home Assistant often reports ‘off’ when a print is paused, mistakenly triggering your power-off automation. To fix this, modify your automation to include a condition that checks the ‘octoprint_print_status’ sensor. Ensure the automation only proceeds if the status is not ‘Paused’ or ‘Pausing’.
What is G-code and why is it important for 3D printers?
G-code is the fundamental programming language for 3D printers. It contains instructions that dictate every aspect of the printing process, including movement of the print head, temperature control for the nozzle and bed, and fan speeds. Sending specific G-code commands, often through interfaces like OctoPrint, allows for direct control and configuration of the printer’s functions.
How do I prevent Home Assistant from turning off a print that was manually paused and then cancelled?
To ensure cancelled prints also turn off the printer, add a secondary trigger to your Home Assistant automation. This trigger should specifically detect when the print status changes from ‘Paused’ to ‘Operational’ (or a similar state indicating cancellation). This ensures that even if the print was paused, if it’s subsequently cancelled, the automation will still execute the turn-off action.
We love having our 3D printer connected to our smart home. Being able to turn it on and off with Home Assistant, a powerful open-source home automation platform, is super convenient. We set up an automation to automatically power down our Creality Ender 3 V2 after a print finished, and it worked great for a while. That is, until our long prints started dying overnight.
The problem was simple: our automation was turning off the printer when a print was merely paused, not truly finished. This led to frustrating restarts and wasted filament. This post will walk you through how we tracked down this sneaky issue and fixed it, so your Home Assistant setup can reliably manage your 3D printer without interrupting important jobs.
We’ll cover how we adjusted our Home Assistant automation, disabled an unexpected printer setting, and even added a small trick to our OctoPrint setup to make resumed prints smoother.
What you need
- A 3D printer, like our Creality Ender 3 V2 with BLTouch firmware.
- A Raspberry Pi 4 running OctoPrint 1.11. OctoPrint is a popular web interface that lets you control and monitor your 3D printer remotely.
- Home Assistant, with the OctoPrint integration already set up. An integration is how Home Assistant connects to and communicates with other devices and services.
- A local smart plug with power monitoring. This is the device Home Assistant uses to turn your printer on and off. Our plug appears as
switch.printerin Home Assistant.
The mystery of the disappearing prints
Our goal was straightforward: when a 3D print finished, and the hotend (the part of the printer that melts the filament) cooled down, we wanted Home Assistant to turn off the smart plug connected to the printer. This saves energy and adds peace of mind. Our initial automation looked at two things: if the printer was no longer printing, and if the hotend temperature was below 50 degrees Celsius.
Everything seemed fine until we started noticing that longer prints, especially those running overnight, would sometimes be found powered off in the morning. This wasn’t just an annoyance; it meant the print was completely ruined. We quickly realized this only happened when a print had been paused at some point.
We checked our Home Assistant setup and saw that the binary_sensor.octoprint_printing entity (a type of sensor that has only two states, like on/off or true/false) was turning off when a print was paused. This meant our automation thought the print was *finished* when it was only *stopped temporarily*. This was the core of our problem.
Uncovering the hidden pause trigger
The next puzzle was *why* our prints were pausing unexpectedly in the first place. We weren’t manually pausing them. After some investigation, we discovered a setting in our Creality Ender 3 V2’s firmware that was causing trouble. Firmware is the permanent software programmed into a hardware device, like your 3D printer, that controls how it operates.
Our printer had a filament runout check turned on. This feature is supposed to pause the print if the printer detects it has run out of filament. However, we didn’t have a filament runout sensor fitted to our printer. Because there was no sensor, the input pin on the printer’s mainboard was reading as “triggered” by default, as if there was no filament. This caused the printer to pause itself, even with a full spool of filament!
To fix this, we needed to disable the filament runout check. We did this by sending a G-code command through OctoPrint’s terminal. G-code is the language that 3D printers understand, telling them what to do, like move, heat up, or print.
First, we sent the M412 S0 command. M412 is the G-code command for filament runout detection. The S0 part tells the printer to disable this feature. After sending this, we sent M500. This command tells the printer to save the current settings to its EEPROM, which is a special type of memory that retains information even when the power is off. Without M500, the setting would revert after a power cycle.
Here are the commands we typed into the OctoPrint terminal:
M412 S0
M500
Refining the Home Assistant automation
With the unexpected pauses out of the way, we still needed to teach Home Assistant the difference between a paused print and a truly finished print. We achieved this by adding a condition to our existing automation. A condition is a requirement that must be met for an automation to proceed after being triggered.
Our updated automation now checks the sensor.octoprint_print_status. This sensor provides more detailed information about the print’s state, such as Printing, Paused, Pausing, or Operational. We added a condition to ensure the automation would *only* turn off the printer if the print status was *not* Paused or Pausing.
However, what if we manually paused a print and then decided to cancel it? The printer would remain on because our automation wouldn’t trigger if the status was Paused. To handle this, we added a separate trigger specifically for when a print is cancelled from a paused state. This ensures the printer still turns off if we decide to abandon a paused print.
Here is the full working Home Assistant automation YAML. YAML is a human-readable data serialization language often used for configuration files, like those in Home Assistant.
alias: '3D Printer: Turn off after print finishes'
description: 'Turns off the 3D printer smart plug after a print completes and cools down'
trigger:
- platform: state
entity_id: binary_sensor.octoprint_printing
to: 'off'
for:
minutes: 5
- platform: state
entity_id: sensor.octoprint_print_status
from: 'Paused'
to: 'Operational' # Assuming 'Operational' means it was cancelled from paused
condition:
- condition: not
conditions:
- condition: state
entity_id: sensor.octoprint_print_status
state: 'Paused'
- condition: state
entity_id: sensor.octoprint_print_status
state: 'Pausing'
action:
- service: switch.turn_off
target:
entity_id: switch.printer
mode: single
This automation uses two triggers. The first trigger watches for binary_sensor.octoprint_printing to turn off and stay off for 5 minutes, giving the hotend time to cool. The second trigger specifically catches the state change from Paused to Operational, which often happens when a paused print is cancelled. The condition then makes sure the printer isn’t currently in a Paused or Pausing state before turning off the power.
Bonus OctoPrint G-code for resumed prints
As an extra step, we added a small optimization to our OctoPrint setup. Our beforePrintStarted script (a script that runs automatically before a print begins) typically includes the G28 command, which tells the printer to home all axes (move to its starting position). This is usually a good idea for a fresh print.
However, if you’re resuming a print, you don’t want the printer to home its axes mid-job, as this would ruin the print. To prevent this, our script now checks if the filename contains the word “RESUME”. If it does, it skips the G28 command. This ensures that resumed prints continue exactly where they left off.
You can find more details about the OctoPrint integration for Home Assistant on its official documentation page: Home Assistant OctoPrint Integration.
What went wrong / gotchas
Our journey to a reliable 3D printer automation had a couple of key stumbling blocks. The first was the unexpected behavior of binary_sensor.octoprint_printing. We assumed “not printing” meant “finished printing,” but it also included “paused printing.” This distinction is crucial for automations that control power.
The second, and perhaps more insidious, issue, was the printer’s built-in filament runout check. Because we didn’t have a sensor installed, the printer was constantly misinterpreting the lack of a sensor as a filament runout event. This led to frequent, unwanted pauses that were difficult to diagnose at first. It’s a good reminder that even if a feature isn’t physically present, its software setting can still cause problems. Learning about the M412 G-code command was essential to solving this.
You can read more about the M412 G-code command and its functions on the Marlin Firmware documentation: Marlin G-code: M412.
By addressing these two issues, the Home Assistant automation’s logic and the printer’s hidden setting, we finally achieved a smart home setup that truly understands our 3D printer’s state. No more wasted filament or ruined prints due to unexpected shutdowns. Our printer now reliably turns off only when a print is truly done, or intentionally cancelled.
FAQ
Why did my 3D printer keep pausing unexpectedly?
Many 3D printers have a filament runout detection feature in their firmware. If this feature is enabled but you don’t have a physical filament runout sensor installed, the printer might incorrectly detect a runout. This causes it to pause prints automatically, even if there’s plenty of filament available. You can usually disable this setting using a G-code command.
How can I stop Home Assistant from turning off my 3D printer when it’s just paused?
The binary_sensor.octoprint_printing entity in Home Assistant turns off when a print is paused, which can trigger your power-off automation prematurely. To prevent this, add a condition to your Home Assistant automation that checks the sensor.octoprint_print_status. Ensure the automation only proceeds if the status is not Paused or Pausing.
What is G-code and why is it important for 3D printers?
G-code is the programming language that 3D printers use to understand instructions. These commands tell the printer everything from where to move its print head and how fast, to what temperature to set the hotend and print bed. It’s essential for controlling precise movements and functions, and you can send G-code commands directly to your printer, often through an interface like OctoPrint, to adjust settings or perform specific actions.






