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’ll earn a commission, at no additional cost to you. Read my full disclosure here.
Advertisement

While the hype surrounding 3D printers might have died down in the last years, they still are a pivotal machine for many makers. A decent 3D printer can unlock a world of custom projects, including those built with ESPHome. These wonderful machines are far from dead; on the contrary, they’re stronger than ever. It’s just the initial, overblown hype from certain outlets has disappeared.

Advertisement

I’m fairly certain that there is quite a significant overlap of Home Assistant users and 3D printer owners, namely due to ESPHome. Why not integrate the 3D printer with Home Assistant and combine the hobbies? This guide will show you step by step how you can do exactly that using OctoPrint and explain why the easy way isn’t the best way.

Table of Contents

Using the native OctoPrint integration in Home Assistant

The easiest way of reading data from your 3D printer with Home Assistant is by using the native OctoPrint integration. Home Assistant should automatically discover a new OctoPrint instance running on your network, and if not, you can choose OctoPrint from the list of integrations.

Advertisement

Enter your details, including the username and host, and make sure you disable both SSL options if you aren’t using any certificates. Once you click on submit, you will need to open a new tab, navigate to OctoPrint, and click on the button titled allow in the notification.

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.

You now have access to sensors such as the current state of the 3D printer, the estimated finish time, target and actual temperatures of both the heated bed and tool, and more. The integration also gives you some basic controls, such as stopping, pausing, and resuming a print.

Advertisement
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. Luckily, there is a better way.

Integrating OctoPrint with Home Assistant using MQTT

While OctoPrint on its own is a good platform, what makes it great are the plugins. You can install plugins that will help you monitor filament spools, send notifications using Pushover, and create a timelapse using a connected camera. The two that interest us in this case are:

Advertisement
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

Once you have installed both plugins, and followed the instructions provided by OctoPrint, you must configure the MQTT plugin. This includes adding your host, port, and, of course, username and password.

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

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.

Configuring the HomeAssistant Discovery plugin for OctoPrint

You only need to fill in three fields to configure the HomeAssistant Discovery plugin: the device name, the manufacturer, and the model of your 3D printer. If you mess with the discovery topic, Home Assistant won’t be able to use MQTT auto-discovery, and the node ID is a random string that 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.

Advertisement
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.

You still have access to the same sensors, but the MQTT integration also tells you whether the connection status of the 3Dprinter, the name of the file you are currently printing, more time options, and the SoC’s temperature. The latter can be used to tell whether you need to move your motherboard outside the enclosure.

In summary, the integration of OctoPrint with Home Assistant via MQTT provides much more detail and should be your choice if you are already running a broker. If you aren’t doing so, you should seriously consider it, if only for OctoPrint.

ESPHome will support the Wi-Fi enabled Raspberry Pi Pico W

Get these discounted, platinum-rated TP-Link Kasa lights and plugs

Advertisement
Liam Alexander Colman, the author and maintainer of Home Assistant Guides.

About Liam Alexander Colman

Liam Alexander Colman has been using Home Assistant for various projects for quite some time. What started off with a Raspberry Pi quickly became three Raspberry Pis and eventually a full-blown server. I now use Unraid as my operating system, and Home Assistant happily runs in a Docker container. My personal setup includes many Zigbee devices as well as integrations with existing products such as my Android TV box. Read on to find out more on how I got started with Home Assistant.

Leave a comment

Advertisement
Share to...