Problems getting event subscriptions to work


I'm trying, for the first time, to get an event to fire my python script. Here is what I put in /home/pi/.octiprint/config.yaml:

  enabled: True
  - event: PrintStarted
    command: python /home/pi/bin/ {__filename} {__now}
    type: system
    enabled: True

It's right after the appearance section in the first 20 or so lines of the file. After I restart Octoprint, I get the following in the logs:

2018-09-23 23:27:28,047 - - INFO - Disabled command trigger: {'enabled': False, 'command': 'python /home/pi/bin/ {__filename} {__now}', 'event': 'PrintStarted', 'type': 'system'}
2018-09-23 23:27:28,279 - octoprint.server - INFO - Shutting down intermediary server...
2018-09-23 23:27:28,305 - octoprint.server - INFO - Intermediary server shut down
2018-09-23 23:27:28,309 - - INFO - Processing startup event, this is our first event
2018-09-23 23:27:28,309 - - INFO - Adding 0 events to queue that were held back before startup event
2018-09-23 23:27:28,315 - octoprint.filemanager - INFO - Adding backlog items from all storage types to analysis queue...
2018-09-23 23:27:28,394 - octoprint.filemanager - INFO - Added 0 items from storage type "local" to analysis queue

and the config.yaml entry has been !changed! to

  enabled: true
  - command: python /home/pi/bin/ {__filename} {__now}
    enabled: false
    event: PrintStarted
    type: system

My script does not get called on the PrintStarted event.

What did you already try to solve it?
I have tried different ordering of the lines in the subscription section but that didn't seem to make a difference. I believe that this section of the python code in _initSubscriptions()

			if "enabled" in subscription.keys() and not subscription["enabled"]:"Disabled command trigger: {!r}".format(subscription))

is making the log entry but I don't know if it is triggered after the config.yaml file is doctored to show enabled as false (it starts out true in my entry). I also don't know what code is changing enabled to false and reordering the lines in my subscription entry.

Additional information about your setup (OctoPrint version, OctoPi version, printer, firmware, octoprint.log, serial.log or output on terminal tab, ...)
I'm running octoprint 1.39 on a Raspberry Pi 3B+ installed using Octopi. It is connected to an Anet A8 running Marlin 1.1.9.

Is there a way to attach my complete config.yaml file and log file to this entry as attachments?


Just a hunch, but what happens if you leave out enabled altogether? It defaults to true.

Also, does the same happen when starting in safe mode?


Removing the enabled entry in the subscription did not change the behavior. However, starting in safe mode did. There was no entry in the log file for disabling the event and, when I started a print, my script got called.


Then some third party plugin is interfering here. What do you have installed?

2018-09-24 10:45:42,762 - octoprint.plugin.core - INFO - 23 plugin(s) registered with the system:
|  Action Command Prompt Support (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/action_command_prompt
|  Announcement Plugin (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/announcements
|  Bed Visualizer (0.1.6) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_bedlevelvisualizer
|  Core Wizard (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/corewizard
|  CuraEngine (<= 15.04) (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/cura
|  Discovery (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/discovery
|  DisplayLayerProgress Plugin (1.7.1) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_DisplayLayerProgress
|  Enclosure Plugin (4.12) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_enclosure
|  Firmware Updater (1.0.0) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_firmwareupdater
|  Logging (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/logging
|  MQTT (0.7.1) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_mqtt
|  OctoPi Support Plugin (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/octopi_support
|  Plugin Manager (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/pluginmanager
|  Preheat Button (0.2.0) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_preheat
|  Printer Safety Check (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/printer_safety_check
|  Printer Stats (1.0.0) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_stats
|  PrintTimeGenius Plugin (1.1.6) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_PrintTimeGenius
|  SMS Notifier (with Twilio) (0.3.2) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_smsnotifier
|  Software Update (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/softwareupdate
|  Tempsgraph Plugin (0.3.3) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_tempsgraph
|  Touchtest Plugin (0.1.1) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_touchtest
|  TouchUI (0.3.12) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_touchui
|  Virtual Printer (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/virtual_printer
2018-09-24 10:45:42,780 - octoprint.environment - INFO - Detected environment is Python 2.7.13 under Linux (linux2). Details:
|  hardware:
|    cores: 4
|    freq: 1400.0
|    ram: 918183936
|  os:
|    id: linux
|    platform: linux2
|  plugins:
|    octopi_support:
|      model: unknown
|      revision: a020d3
|      version: 0.15.1
|  python:
|    pip: '18.0'
|    version: 2.7.13
|    virtualenv: /home/pi/oprint


Can I assume that the bundled plugins are not a problem and only try removing the "aftermarket' plugins?


Yes. Safe mode keeps those on, it only disables third party/non bundled plugins. If your issue doesn't show in safe mode it's neither core OctoPrint nor any of the bundled plugins.


So, to get get to the bottom of this, I need to disable them one at a time until it works?


The answer is likely yes.

I think I'd start toggling them off in this order:

  1. Preheat Button
  2. SMS Notifier
  3. PrintTimeGenius
  4. Printer Stats
  5. Touchtest Plugin
  6. TouchUI