Tuesday, January 3, 2017

Adding IFTTT to your OctoPi

I recently got a 3d printer (i3) and setup OctoPi as a controller.  It has a ton of plugins but I was surprised there isn't an IFTTT plugin.

I might get around to writing a proper plugin, but in the meantime here is a shell script hack...

Note: Setup your Maker Channel and make a note of your key to update the commands below...

Location: /home/pi/scripts/ifttt-maker.sh

#!/bin/sh
KEY=INSERT_KEY_HERE
curl -s "https://maker.ifttt.com/trigger/$1/with/key/\
$KEY?value1=$2&value2=$3value3=$4" > /dev/null
Then simply call the script /home/pi/scripts/ifttt-maker.sh TRIGGER value1 value2 value3 A simple example would be to make an Applet on IFTTT with the Maker channel receive webevent as a trigger using the trigger keyword "OctoPiPrintComplete" and an action using the iOS Notify channel. /home/pi/scripts/ifttt-maker.sh OctoPiPrintComplete "Done" Next step would be to add this as an event subscription in config.yaml....   I'll add that to another post.  (I envision sending the elapsed time as the value1 field)

2 comments:

  1. To send events to IFTTT add this to your config.yaml (/home/pi/.octoprint/config.yaml for me):

    events:
    enabled: true
    subscriptions:
    - command: /home/pi/scripts/ifttt-maker.sh OctoPiDisconnected {port}
    enabled: true
    event: Disconnected
    type: system
    - command: /home/pi/scripts/ifttt-maker.sh OctoPiPrintStarted {port}
    enabled: false
    event: PrintStarted
    type: system
    - command: /home/pi/scripts/ifttt-maker.sh OctoPiPrintComplete {name} {time}
    event: PrintDone
    type: system

    ReplyDelete
  2. Made a plugin for this: https://github.com/sedgett/OctoPrint_IFTTTmaker

    ReplyDelete