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.
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
- Integrating OctoPrint with Home Assistant using MQTT
- Conclusion: Use MQTT to integrate OctoPrint with Home Assistant
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.
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.
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.
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:
- MQTT: Adds support for subscribing and publishing to MQTT topics
- HomeAssistant Discovery: Automatically add your OctoPrint server to Home Assistant with MQTT
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.
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.
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.
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.