I have been trying for two days now to get this to work and I just can't get there - please help!
I have a servo set up and run through an Adafruit 16 channel PWM servo hat on my Octopi. Its purpose is to use a servo to deploy a brass bristle brush over the print bed that the extruder then passes over before a print to clean the nozzle of any hanging "buggers" before starting a print.
The board is wired and functioning properly, all libraries are installed. I created two python scripts, one to deploy the brush called deploy.py:
import time
from adafruit_servokit import ServoKit
kit = ServoKit(channels=16)
kit.servo[0].angle = 110
and one to retract the brush after cleaning called retract.py:
import time
from adafruit_servokit import ServoKit
kit = ServoKit(channels=16)
kit.servo[0].angle = 0
logged in as pi in a terminal I can run those scripts successfully by issuing "python3 deploy.py" or "python3 retract.py" from the home directory (/home/pi). I searched FOREVER to find a way to pass system commands from GCode in my print files to the OS layer to activate that servo, and FINALLY I found and installed the GCode System Commands plugin. I thought Hurray! An Answer! Got the plugin installed and at first I tried setting OCTO10 to the command line python3 /home/pi/deploy.py. Issue OCTO10 from teh Octoprint Terminal - error - nothing happens with the brush. So then as I looked, I thought OK, looks like all the examples are shell commands so I created shell scripts for each (you guessed it - Deploy.sh and retract.sh):
deploy.sh:
#!/bin/bash
python3 /home/pi/deploy.py
retract.sh:
#!/bin/bash
python3 /home/pi/deploy.py
I have tried EVERY single permutation of that shell script I can think of, including trying the ultra-stupid of issuing sudo for it and passing the password hard-coded in the script, JUST to see if I could get the damn thing to work (and yes, both shell scripts are set to executable). No go - always results in:
Traceback (most recent call last):
File "/home/pi/deploy.py", line 2, in
from adafruit_servokit import ServoKit
ImportError: No module named 'adafruit_servokit'
I can NOT figure out for the LIFE of me WHY it knows where the module is, and properly executes it from the Raspberry terminal command line, yet issue exactly the same command in a shell script and it blows up saying it can't find a module that is indeed there. Of course with this, any attempt to run either the shell script, or just the plain python command line in the plugin ALWAYS results in:
Exec(GCodeSystemCommands): OCTO10
Return(GCodeSystemCommands): error
Which, is so helpfully verbose..... Please, can anyone set an old guy straight?