I need to run a script that toggles a fan and led strip on and off. The command runs like this:
control.py fan true
I wanted to add two buttons (possibly the ON/OFF type GPIO Control uses) to toggle the strip and the fan.
What did you already try to solve it?
So far, I tried:
GCODE System Commands, creating a GCODE command that both runs the script directly (command = control.py fan true) and one that runs a wrapper bash file that runs the python file (command = run_script.sh). Both times, running from the terminal returns error.
Custom control editor, which does not work for running a Python script directly. Running the custom GCODE, unsurprisingly, does not work either, because the command does not work either.
System command editor: I managed to make it work by adding a button to the system control interface using System command editor, but this would require 4 entries (led on/off, fan on/off).
After rereading your original post I see you tried this. Probably wasn't working because you didn't use full path to the python file, it wasn't chmod +x to be executable and didn't have the python interpreter set as first line in file (#!/usr/bin/env python3).
Now seems a good time to add what was in the shell file, I forgot to add it in the OP:
#!usr/bin/python3
/usr/bin/python3 ~/scripts/control.py fan true
While I did put the wrong "header" in the file, isn't this the full path to the script?
Also, I did chmod a+x the .sh script, should I just have done +x?
Custom device based off an ESP8266, controlling two MOSFETs that control a 12V LED Strip and fan.
The communication is based on the Firebase RTDB, because it's quite easy to integrate with all the systems I'm using (MIT App inventor, ESP8266 and Python).
I made all of this so I could control the fan and strip:
remotely, with the MIT App;
from within OctoPrint, with the custom buttons I'm trying to make;
automatically, as in turning the fan on and off automatically when a print starts/ends.