Troubleshooting a broken Octoprint Integration

A situation came up - my Octoprint/printer page wasn't working like it should.

  • Power could turn on and off - not a problem
  • Sensors would show temperatures and status - not a problem
  • Buttons that sent commands back to Octoprint no longer work - PROBLEM

The electrical power for each printer is managed by a TP Powerlink, each plug is managed by a different entity. It does not use Node-Red, and buttons for the power worked for both printers. This was not helpful.

The Octoprint integration shouldn't be touching the button flows. The sensors were live, so the HA integration was probably not the case.

This is using Home Assistant Core 2022.5.3. With a recent release, the developers changed things up. For example, to check your configuration.yaml and restart your server - previously it was found at Settings>System. (As a caution, the "help" text for that option still indicates the reboot is found there.)

Instead, it is found under Developer Tools>YAML - both the configuration check, and the server/services reboot.

Troubleshooting Steps

Outlining what areas could be generating the errors:

  • Home Assistant itself
  • Node-RED flows
  • MQTT broker (Mosquitto, run within Home Assistant)
  • MQTT subscribe plugin on the printers (the actual Octoprint software on its own Raspberry Pi)
Home Assistant is a broad area - this was just looking at Home Assistant only. The MQTT entry in the configuration.yaml was fine.

Node-RED seemed like a possible culprit. None of those buttons were kicking off commands on the printer side.

My system for sending Octoprint commands through Node-Red is the same as documented before.

  1. An "events: state" node, checking the state of the button
  2. A "template" node, containing the outgoing message
  3. A MQTT-out node, a wrapper for the message to the specified MQTT topic
  4. On the printer's side, it listens for specific MQTT topics and will act on specific messages received on those topics

Wired up a couple of debug nodes attached to the template nodes - the buttons triggered them. Node-RED was likely not the issue.

Mosquitto Broker

The MQTT broker is hard to test by itself. It sends messages out - if the message is not received, is it the fault of the sender (the broker) or receiver (subscriber on the printer)? Turning on the MQTT Explorer software on my Ubuntu laptop, it couldn't connect to the broker. Either MQTT Explorer no longer worked, or it was a broken broker...or both.

This was the painful part. It was difficult knowing what was broken, but also did not want to rip everything out and start over again. After an hour of troubleshooting this step, reinstall seemed the most likely course of action. Went over my initial notes, watched a random youtube video on setting it up, and uninstalled/reinstalled.

It's important to be patient - rebooting Home Assistant and starting up services can take several minutes. The broker came up. MQTT Explorer was used to send a message on a topic to the printer - the pop-up on the printer's webpage worked. Most importantly, the buttons worked again

The best part was: nothing had to be done to the pre-existing Node-Red flows, MQTT subscriptions on the printers, or even just the configuration.yaml file.

The Wrap-Up

I felt the broker was the problem from the beginning, but it was more complex to rule out. The broker integration was also broken in a way that I couldn't test it correctly. 

I even went back to using pre-Home Assistant print job processes to avoid broker woes. MQTT was difficult to set up the first time, making it not a fun part to dissect.

I did all of this setup for a reason though - it saves time and effort in the long run.



Comments

Popular posts from this blog

Home Assistant Controlling Octoprint through MQTT - Chapter 1

Setting up MQTT on HA and Octoprint

Home Assistant Controlling Octoprint through MQTT - Chapter 2