Safety MQTT Plugin for Octoprint

I searched around a bit and although there are some MQTT plugins, I didn't find anything like what I'm thinking here. Pretty much all I found was related to controlling or monitoring OctoPrint using MQTT.

The Marlin firmware, and I assume OctoPrint, have safeties built in to detect and stop thermal runaway, such as say the temp sensor falls away from the bed or fails - this way it doesn't keep the heater cranked to the max trying to hit its target, but it'll never know that it reached and passed it and is now running away because the sensor has fallen away or failed, so obviously, if the firmware is commanding heat and it's not seeing the temp increase like it should, out of safety, it assumes something's gone wrong and it'll shut down.

This is great for cases like that, but where no firmware solution can help directly is if a MOSFET or TRIAC were to fail closed, which I gather they often do when they fail. The problem is in that case, there's nothing the firmware can do to stop it. It can command the heat off (or just plain halt the controller, effectively shutting it all down), but if the MOSFET or TRIAC is melted closed, it'll never shut off - You need to remove the power.

Enter my thought. I have a ZWave network set up in my home and I run my printer through a ZWave switch so that when I run out while a print is running, I can jump in and check on it from time to time, and if I see something's gone sideways, I can cut power to the printer remotely. But obviously, I can't be watching all the time.

So what I'm thinking is a plugin that can send MQTT messages based on defined parameters - such as the bed temperature has hit 150c (In my case, there's no reason it would ever need to get over 100c, so if it does, there's a problem). This way I could configure it so that in the event of a problem like the bed or hot end reaching a temp well above what it should, it'll send a MQTT message to my home automation controller to cut power to the printer.

Does anyone have any thoughts on that? Is there anyone that might be able to create such a thing?

My own approach to something like that would frankly be to just wire the regular MQTT plugin into NodeRed (or another rules engine) and use that to trigger such an automation.

But then again I have this whole HomeAssistant-NodeRed-Grafana stack running here anyhow.

1 Like

That works when you have that kind of stack set up, which is great. I too am using HomeAssistant, and have hardware running that puts most SMBs to shame. I messed with NodeRed some time back, but I threw in the towel because I couldn't manage to get it to do whatever it was I was trying to do at the time, and Grafana looks pretty neat. But most wouldn't have that kind of setup just for the purpose of killing power to their printer should something go sideways, but a lot of people have some form of home automation, and I'd imagine a lot of the home automation solutions out there could accept MQTT messages (could be wrong, thought), so OctoPrint sending a MQTT message would be a simpler approach. I'm not really stuck on MQTT though... if there's something else, like API push requests that would be more broadly usable, that too would work - I'd imagine HomeAssistant could work with some sort of API push too...

If you install the MQTT plugin and point it at your HomeAssistant for it's MQTT broker, then can't you react to those messages?

I don't believe so because HomeAssistant would require a specifically crafted message to act on it. For example, I set up a Rasperry Pi with a button connected to a GPIO pin to toggle my daughters rooms light when pressed. The MQTT message sent to do that was 'publish.single("hass/light/Natalie", "Toggle", hostname="xxx.xxx.xxx.xxx", auth=auth)'. So basically, to kill the power to the printer, it would have to be something along the lines of 'publish.single("hass/light/3dPrinter", "off", hostname="xxx.xxx.xxx.xxx", auth=auth)'. The syntax and actual naming may be off a bit, but that's the general idea of what would need to be sent to HomeAssistant to tell it to turn off the switch powering the printer.

I might be wrong, but isn't their an OctoPrint integration for HA? Then you could use automation rules to do whatever against the sensors added? I've never tried it but I bet @foosel does since she has both...

And a couple of videos on how to setup...

And what is the problem? Buy a 5€ Wifi Plug, flash Tasmota... and switch the plug.