How to integrate your 3D printer with Home Assistant using OctoPrint

Disclosure: This post contains affiliate links. If you click through and make a purchase, I will earn a commission, at no additional cost to you. Read my full disclosure here.

The Prusa Mini 3D-printer, printing a rectangle out of grey plastic.

It's highly likely that many Home Assistant users are also 3D printer enthusiasts, thanks in part to ESPHome. Why not bring these two interests together by integrating your 3D printer with Home Assistant? This guide will walk you through the process of achieving this integration using OctoPrint, while also explaining why the most straightforward approach may not always be the best.

3D printers are thriving

Though the initial buzz around 3D printers may have settled down, these innovative devices continue to be indispensable tools for many creators. A reliable 3D printer can open up a realm of custom projects, including those crafted with ESPHome. Far from becoming obsolete, 3D printers are thriving, albeit without the exaggerated hype of their early days.

An isolated image of the Prusa Research Original Prusa MK4.

Using the native OctoPrint integration in Home Assistant

The most straightforward method for syncing your 3D printer with Home Assistant is by utilizing OctoPrint's native integration. Home Assistant should automatically detect any OctoPrint instances running on your network, but if it doesn't, you can manually select OctoPrint from the list of integrations.

A screenshot showing how OctoPrint can be integrated with Home Assistant. There are text fields for the username, host, port number, and application path. Additionally, there are options to use SSL and verifying the SSL certififcate.
A screenshot of an OctoPrint notification, asking whether the user wants to give Home Assistant access using the OctoPrint API.

Input your details, including username and host, and remember to disable both SSL options if you're not using certificates. After clicking 'submit', open a new tab, navigate to OctoPrint, and click the 'allow' button in the notification.

What the OctoPrint integration with Home Assistant grants you

This integration grants you access to sensors such as the 3D printer's current status, estimated completion time, target and actual temperatures of both the heated bed and tool, among others. Additionally, you'll have basic control functions like stopping, pausing, and resuming a print.

A screenshot of the controls and sensors the native OctoPrint integration with Home Assistant gives you. These include controls to pause, resume, or stop a print. Sensors include the current state, estimated finish time, job percentage, printing, printing error, start time, actual bed temp, actual tool temp, target bed temp, and target tool temp.
I have hidden any sensors that aren't applicable to my setup

You can also set up automations, such as sending a notification to your mobile phone whenever a print has finished or the printer encounters an error. While this integration does seem fully featured, it is not what I recommend for those that want total control. For example, the native OctoPrint integration with Home Assistant does not allow for control of OctoPrint itself, nor does it provide you any information on the print. Fortunately, there's a more advanced alternative.

Enhancing the OctoPrint integration with Home Assistant using MQTT

OctoPrint is a powerful platform in its own right, but its true potential is unleashed through the addition of plugins. These nifty extensions can help you keep tabs on your filament spools, receive notifications via Pushover, and even craft timelapses with a connected camera. For our purposes, we'll focus on two particular plugins:

A screenshot of two plugins for OctoPrint: MQTT and Home Assistant Discovery.

As the name would suggest, these plugins require an MQTT broker, the setup of which I will not be covering here. If you, like me, are running Home Assistant in a Docker container on Unraid, I have a post detailing the setup of the Mosquitto MQTT broker on a sister-site. If you already have a broker setup, this integration is a no-brainer.

Configuring the MQTT plugin for OctoPrint

After installing both plugins and following OctoPrint's instructions, it's time to tweak the MQTT plugin. This entails inputting your host, port, username, and password.

In the tab titled topics, you can select which events the plugin publishes via MQTT. These options should give a clue as to how much more information OctoPrint sends to Home Assistant, compared to the native integration. Finally, you also have the option of customizing or disabling the last will and status messages.

A screenshot of the MQTT plugin's configuration in OctoPrint.

Configuring the HomeAssistant Discovery plugin for OctoPrint

Configuring the HomeAssistant Discovery plugin is a breeze – simply fill in three fields: your device name, the manufacturer, and your 3D printer's model. Avoid tampering with the discovery topic, as this may prevent Home Assistant from utilizing MQTT auto-discovery. The node ID, a random string, can be left as is.

A screenshot of the Home Assistant discovery plugin in OctoPrint. It allows the user to set a device name, manufacturer, and model.
Only the three lower text fields need adjusting

Conclusion: Use MQTT to integrate OctoPrint with Home Assistant

With both plugins configured, Home Assistant will discover the entity and automatically add controls and sensors. Compared to the native OctoPrint integration, this options not only allows you to pause/resume/stop a print, but also gives you control over the system. You can reboot or shutdown the system, or restart the OctoPrint server if something is going wrong. Additionally, you have access to an emergency stop button, and you can control OctoPrint's connection to the 3D printer.

A screenshot of the OctoPrint integratio with Home Assistant when using MQTT. It shows the following controls: Cancel print, connect to printer, emergency stop, pause print, reboot system, restart server, and shutdown system. The sensors shown are: Approximate completion time, approximate total print time, bed target, bed temperature, connected, current z, print progress, print status, print time, print time left, printing, slicing progress, SoC temperature, tool target, and tool temperature.

Moreover, the MQTT integration retains access to the same sensors while enhancing your monitoring capabilities. It keeps you informed about the connection status of the 3D printer, the file being printed, additional time options, and the SoC's temperature. This valuable data can help you determine if relocating your motherboard outside the enclosure is necessary.

To sum it up, integrating OctoPrint with Home Assistant via MQTT offers a comprehensive and detailed user experience. If you're already running a broker, this should be your go-to choice. And if you're not, it's time to give serious thought to embracing MQTT for an upgraded OctoPrint experience.

A portrait photo oif Liam Alexander Colman, the author, creator, and owner of Home Assistant Guide wearing a suit.

About Liam Alexander Colman

is an experienced Home Assistant user who has been utilizing the platform for a variety of projects over an extended period. His journey began with a Raspberry Pi, which quickly grew to three Raspberry Pis and eventually a full-fledged server. Liam's current operating system of choice is Unraid, with Home Assistant comfortably running in a Docker container.
With a deep understanding of the intricacies of Home Assistant, Liam has an impressive setup, consisting of various Zigbee devices, and seamless integrations with existing products such as his Android TV box. For those interested in learning more about Liam's experience with Home Assistant, he shares his insights on how he first started using the platform and his subsequent journey.

Comments

  1. If you use the standard integration, and are using https:// for octoprint web app, don’t forget to check Use SSL AND ALSO CHANGE THE PORT TO 443!!

    Can’t believe I spent nearly 40 minutes banging my head over that.

    Reply

Leave a comment

Share to...