Busy State / Color Change / Push Updates / Event for a certain Command

Hi!

I'm writing a small utility for my set of three printers, so that I don't have to always have the octopi webpages loaded in three tabs. (And this way I can keep them all shown at once on, for example, a cheap tablet).

Everything is fine right now but I'm looking to add a few more features, if possible. Here are my questions:

  1. Color change. If the printer got a M600 command, it's pausing and beeping, but I might not be close enough to hear that. I'd like to be able to tell that's happening, but I don't see any way currently. I think that either the ability to see the state of the printer as busy, or being able to see that a M600 command was recently sent, would be a way to do this.

  2. Z-index display. I might be missing something simple, but I don't see anything that shows the current z-index value. This could also be implemented by seeing the last matching command of a filter.

  3. In the case the above had to be implemented as more of an "event" rather than a "state", it wasn't clear how to setup my application to subscribe to these events. Currently, I am just polling every 60s a few of the /api paths. Have I missed something obvious in the documentation? If there is no documentation, does anyone have a suggested part of the octopi source to start reading?

Thank you for your time and attention.

There are events as described in the documentation. One of them is PrintPaused which sounds like one of the things you're interested in. It includes position.z, for what it's worth. And yet, it only fires on pause-related events.

A little lower in that same section, read about the ZChange event.

The way of doing this might be to edit the ~/.octoprint/config.yaml to inject the script you want to run on either of these events. I seem to recall adding something like this to my printer only I'm not at home right now so I couldn't just copy/paste it here.

And for what it's worth, I'm showing progress detail on my TFT screen using a Conky interface. I'm polling every thirty seconds using a Node-based script which uses octo-client behind the scenes.

Thanks, I had missed the zchange bits under events, since I hadn't yet figured out how to setup subscription yet. The utility I'm writing is a single page html file so that I don't need a server, just a browser. It doesn't look like octo-client does any subscriptions either, it just organizes the api calls for your convenience.

I guess if I can subscribe, I'll have no trouble with the z-level. Unfortunately, the 'paused' isn't the same as the busy/color change. When the print is paused, it seems to be an octoprint state, not related to anything the printer is experiencing (other than a lack of commands being sent to it). When I say busy, the printer will send a busy state (I forget off hand how this is communicated), but I don't see anyplace that octoprint records that.

But, I don't strictly need that busy state, I could also use knowledge of what gcode has been recently sent, that would be sufficient, since I only care about specific commands -- in this case M600 -- being sent recently to the printer. But the busy state would be just as good.

You mention being able to run a custom script in the config.yaml, that is interesting. However, it seems I can only run shell commands or send actual GCODE. I think what I would need is an actual octoprint plugin which would be more privileged and be able to augment the api. Hopefully, I would not have to do so, and I can just use what's available directly.

But, thank you very much for the information!

Yes, you can run a shell script from the event mechanism (config.yaml) or if you'd like, you can send a GCODE command (which technically can be something you've created using the Gcode Systems Command plugin).