Can't seem to get events to work


What is the problem?
I added some scripts to my config.yaml (in ~/.octoprint/config.yaml) to be called when certain print events happen, but they never get called.
What did you already try to solve it?
I made sure the script was working correctly by running it normally.
I also tried resetting the raspberry pi (I have the stock octoprint image, and octoprint is version 1.3.7, according to the 'about Octoprint" in the settings menu).
I looked up some examples from other people, but mine looks the same to me.
Additional information about your setup
Here is what I added to the bottom of my config.yaml file:

  enabled: True
  - event: PrintStarted
    command: /home/scripts/ 1
    type: system
  - event: PrintDone
    command: /home/scripts/ 2
    type: system
  - event: PrintFailed
    command: /home/scripts/ 3
    type: system
  - event: PrintCancelled
    command: /home/scripts/ 4
    type: system

Then this is the script that should run (and works when I run it normally):

#! /usr/bin/python
import sys
import time
print "Lights would have been toggled!"

f = open("/home/pi/test"+ str(time.time()) + ".txt",'w')



I'm not used to seeing a space after the shebang. Maybe this version instead which specifically asks for v2:

#!/usr/bin/env python2

Also, I note that I have three python installs on my own Raspi:

/usr/bin/python (v2.7.13 this appears to be the globally-available version)
~/oprint/bin/python (v2.7.13 this appears to be OctoPrint's virtual environment
~/OctoPrint/venv/bin/python (v2.7.13 since I develop)


Yeah, so I can certainly take out the space and try it, but I've been putting the space in forever. When I run it on command line I just do ./toggleLights and it works fine. I'll also try ~/oprint/bin/python too. It's weird that nothing happens. Is there a way to find debug information? Like what happens if it can't find a script I ask it to run? Is there a log that would say something?


Is there a reason you're not explicitly just using python as the command as in these examples?


  python /home/scripts/ 1

Note: their example refers to home-centric locations for the scripts, as in ~/ but you have your scripts loaded in a place that suggests there's a user named scripts. Does the pi user have access to another user's home folder? Probably not.

Assuming that scripts is another user, you could run some commands to add rights so that pi has access to it... only I think I'd just put the scripts somewhere else like ~/scripts instead.


Wow. You're totally right. Stupid mistake. I'll try that right away. Pretty sure that's it. it was supposed to be /home/pi/scripts. I'm an idiot. Sorry about that. Hopefully it works now.


I'm a software development instructor, does it show? :laughing:

Make sure to mark that reply if it solved your problem. Thanks.


That was great! Thanks! Also, while I have you here, is there a place to see logs? Somewhere something tried to run the script and couldn't find it. Does octoprint record logs of that somewhere? I looked through the logs in ~/.octoprint/logs/, but none of them mentioned anything about errors when trying to use this event. They just said there were 4 registered events.

  • Programmatically, it's here
  • Physically from an ssh session, you'd be interested in ~/.octoprint/logs/octoprint.log
  • From the web interface, they're available in Settings -> Logging

In theory, you could go to the web interface I just mentioned, choose the + button and add octoprint.util.commandline with DEBUG and it may start collecting data into a new log which indicates what's happening when it reaches out to run scripts.


Excellent. Thanks so much!