Push updates instead of polling


#1

I have two octoprint servers. One for each of my printers. I'm trying to integrate them into my homeautomation system. I can poll the printers ever few seconds but most of the time they are either off (the servers and octoprint are up, just the printers are off) or idle. Rather than spend all those useless polls it would be nice if octoprint would allow me to subscribe to events and get a push notification. Based on the documentation I found, it looks like the push updates functionality should do this. But I need an example of how this should work. It says it uses socketJS but at the same time, it seems like it just sends a json string. Is there any additional documentation on the push update functionality along with examples maybe?
My fallback will be to setup a shell script that toggles a sensor in my home automation system telling it that the printer is on and connected. Then poll continually while the printer is on, until I get some type of message telling me the printer is no longer connected. Still not what I'm looking for but closer.


#2

It sounds like you want to be an event handler.

I use the MQTT plugin, which operates in that way. Your home automation platform may have a hook for MQTT.


#3

Never really been a fan of MQTT speed. But that was more dealing with light switches, etc. Registering a printer turning on isn't as realtime dependent I guess. But I am still curious about the push update feature.


#4

If I'm curious about stuff like this, I think I would write a quick-and-dirty server and see what is logged to it when the event fires off.