Close

OctoPrint and Triggers

A project log for Project Stark Framework

This is a YET ANOTHER attempt at an "Iron Man" Jarvis-like system

robweberrobweber 07/09/2016 at 15:030 Comments

If you're familiar with 3D printing, you've probably at least heard of OctoPrint. It is an awesome web app designed to let your 3D printer go "headless". You can store 3D print files, take time lapse video, and control aspects of your printer with OctoPrint rather than connect via a USB to your computer. For the purposes of the Stark Framework, OctoPrint is great because it comes with a REST API.

I have a LulzBot Mini 3D printer connected to OctoPrint. To help automate some tasks I've also developed a small java library to work with the OctoPrint REST API and then created a Stark Module to issue commands. To get some push events going I went the extra mile of writing a small OctoPrint Plugin that will push commands like "Print Complete" to Stark for immediate notification. Using this integration I was able to create some of the most complex rule sets Stark has been able to do so far.

What Is In the Video?

In this video I'm trying to showcase a few things. The first is the OctoPrint integration, the second is some advanced Job setup, and the third is the Trigger system. The Trigger system is something I haven't really touched on before. Most of the things I've shown so far are very simply give command, perform action type scenerios. The Trigger aspect of the Stark Framework allows a Trigger to be setup for a specific type of event. When that event happens it will trigger a Job to perform other actions. A simple example of this might be when an event from Kodi is sent like "PlaybackStopped" it could trigger and event to turn lights on in your living room. Triggers can have some additional conditional properties related to time, or the nature of the event.

In order, the actions performed in the video are:

  1. Issue a command to start the 3D printer. This will trigger SmartThings to turn on the outlet the printer is connected to, as well as tell OctoPrint to connect to that printer.
  2. Issue a change filament command. This is a custom command for convience that moves the print head into an easy-to-access position, and heats the hotend to the temp needed to change out the filament type.
  3. Issue a start a print job command. Pretty basic, start the print job.
  4. Activate shutdown trigger. Activate the trigger for the "PrintComplete" event. This will make Stark issue the commands to disconnect from the printer and turn off the SmartThings switch when the print is complete.
  5. Ask for a status update. Ask Stark for the progress of the print job in two different formats. The first via CLI, and the second via SMS. Since SMS can display picture messages, Stark will forward a screenshot via the webcam from OctoPrint to the device.

The picture function is something that can be utilized by any module by setting a picture into the MEDIA_URL variable in the response. It is up to the Client to decide if this will do anything when it is available. Some clients, like the BASH script interface, do nothing. Others, like IM or SMS integration, can display pictures and will grab the image.


Discussions