Add Webhooks to your 3D printer with OctoPrint

To monitor my 3D printer, I recently got a Raspberry Pi with a camera and installed OctoPrint. This has allowed me to view the progress of my builds from anywhere and check on them from time to time to make sure something hasn’t went horribly wrong. It has worked great so far, but there are a few upgrades I wish my setup had.

  1. Ability to control the power to my Prusa Printer from OctoPrint. It would be awesome if I could leave my Raspberry Pi running all of the time and turn on/off my Prusa Printer (and maybe some connected lights). This would not only save time/power, but give me piece of mind.
  2. Ability for the Prusa to clear itself when a print is done. If this were possible, then you’d be able create a queue of prints that would occur one after the next without a moment waisted.
  3. Ability to get notified when a print has finished or when a color change is necessary.

#1 seems possible and might be something to look into in the future.

#2 could get really complicated. I’ve seen videos of people using their print heads to knock the printed parts off of the print bed. This seems chaotic and unreliable.

#3 is definitely possible. Let’s start with that.

OctoPrint Event Notifications

OctoPrint has a ton of plugins that can be easily installed and add features to your setup such as custom stats, visualizations, ... There are even a few plugins that will notify you through IFTTT, Telegram, Slack, etc. when your print is done, but I couldn’t find a generic webhooks plugin that would allow me to send events to my own server for processing. So, I built one.

The plugin is called OctoPrint-Webhooks and is available for download https://github.com/2blane/OctoPrint-Webhooks. You first enter in a url that will be called whenever an event (such as Print Finished) occurs. Then, you set an optional Security Key. This allows you to check the Security Key in your own API to make sure the webhook came from your OctoPrint device. Then, you give your printer a name so that you can distinguish the printer from all of your other printers. Finally, you check some boxes for the events you want triggering a webhook.

One issue I ran into was when printing a multi-colored part. When it was time to change colors, Prusa would beep and inform me, but there was no discernible event triggered in OctoPrint. So, there was no way to send a webhook. After a lot of searching, turns out there is a special message being logged to the serial console. By having my plugin look for that message, I was able to create a custom event for color changes. Problem solved.

The plugin is very simple to setup and get working with your custom API. You can now flash your Hue Lights or send a text when a print is complete. You can also log all of the events in a custom database to track print usage. There are endless possibilities.

Now that my Prusa has custom notifications, it’s time to start looking into powered control of my printer from OctoPrint and automatically clearing the print bed.