Technology Solutions for Everyday Folks

OctoPrint Webhook for Filament Change Notifications

I've been using OctoPrint to handle nearly all of my 3D printing operations since I moved to it a little over a year ago. It's an absolutely wonderful platform and I can't recommend it enough.

I'd created a rudimentary way to get "notices" from any given print job by way of the OctoPrint integration in Home Assistant. From Home Assistant, I could relay basic messages to Slack, such as print percentage complete (or completion), along with any obvious errors or changes in printer state. This itself was a great help to me as I keep the printer in my basement (on a different floor from where I normally work, etc.).

Basic Notifications are Great, but "Filament Change" Isn't a State

Until recently, what I had set up to ping me in Slack worked just fine. However, one notification I could not get through my configuration was nuanced print status...such as filament change.

As I prepared for MMS Miami this fall, I ended up printing a bunch of tchotchkes for attendees and speakers, and also printed a smaller bunch of similar items for the community theatre. Most of these items were printed in batches, but they all had five or six filament changes per run. I'd often start the jobs right away in the morning and attend to them as necessary through the day (at filament change). However, doing so effectively was a bit of a challenge as I was juggling other projects, work, session prep, and so forth. I wasn't always near to watch the camera action live, monitor OctoPrint, or even be in earshot of the familiar beeping for a filament change. I was "limited" to the data exposed to Home Assistant, and Filament Change is a GCode command, not an actual state.

All of that caused some delayed changes and unnecessary idle time for the printer. I put a real resolution on my bucket list of things to look at once I got back from MMS Miami.

There Has GOT To Be A Way

I started with some basic Googling to come up with ... nothing useful. Until I found the closest thing to it: the OctoPrint plugin Webhooks!

Webhooks Are Good, But...

Out of the box the Webhook plugin was pretty cool, and maintained by someone. It also provided (in a single package) what I had cobbled together for notifications through Home Assistant. But still I was stuck with more normal state changes and standard events. Filament Change wasn't one of those built-in things.

The Event Rabbit Hole

The Webhook plugin exposes a way to handle custom events. So I spent some time digging through the rabbit hole of OctoPrint Events, and discovered the GCode processing section...where I found it!


Per the documentation:

An M600, M701 or M702 was sent to the printer through OctoPrint (not triggered when printing from SD!)

This is exactly what I was looking for — GCode-level notifications. And Cura is configured to send an M600 command for the Marlin filament change.

With a reasonably simple configuration of a Custom Event in the plugin, I had my Slack notification set up!

Screen Snip of Webhook plugin configuration showing Event Name "FilamentChange" and the accompanying Message to send to Slack

When it was triggered, I get this wonderful Slack notification:

Screen Snip of Slack notification to change the filament.

It still claims to be coming from Home Assistant because I'm using the same Webhook and Slack App I set up for other HA notifications. Since it hits my special printing channel I don't really care what "App" it's coming from. I just need the notification...and now I have it!

This was not a rabbit hole I'd expected to traverse, but it helped solve the problem I was encountering. As a result, and since my return, it works exceptionally well and helps me keep things going without the need to constantly monitor the OctoPrint interface.