Read the statement by Michael Teeuw here.
MMM-GroveGestures -> ShellExec "Python script"
-
Good day fellow builders,
I’m building my second MagicMirror and it works for 95%.
I’m using the MMM-GroveGesture module to switch between Pages (MMM-Pages and MMM-Page indicator).I’m having WS2801 LED’s connected. For these LED’s I wrote two Python scripts. When executing the python scripts in the RPI (4) terminal they work flawless.
However I want to activate the scripts by the gestures. So with the up gesture, switching on the LED’s, and with the down gesture, switching them off.Reading the MMM-Grove Gesture module readme I can use three types of executions:
- shellExec: “…”,
- notificationExec: { … },
- moduleExec: { … },
Now I’m a bit lost. I tried to use the shellExec command, but it does not start my python script. If I change it to for example ‘sudo reboot now’ the execution of the gesture does work. Here is (a part) of my config file:
{ module: "MMM-GroveGestures", position: "top_right", config: { autoStart: true, //When Mirror starts, recognition will start. gestureMapFromTo: { //When your sensor is installed with rotated direction, you can calibrate with this. "Up": "RIGHT", "Down": "LEFT", "Left": "UP", "Right": "DOWN", "Forward": "FORWARD", "Backward": "BACKWARD", "Clockwise": "CLOCKWISE", "anti-clockwise": "ANTICLOCKWISE", "wave": "WAVE" }, defaultNotification: "GESTURE", pythonPath: "/usr/bin/python", // your python path defaultCommandSet: "default", commandSet: { "default": { "LEFT": { notificationExec: { notification: "PAGE_INCREMENT", payload: null } }, "RIGHT": { notificationExec: { notification: "PAGE_DECREMENT", payload:null, } }, "UP": { shellExec: "sudo reboot now", }, "DOWN": { shellExec: "python ws2801_uitschakelen.py", } }, }, } },So I’m wondering, how to start my python script with this module? Anyone can point me in the right direction? Thanks in advance.
Regards Robert
-
sorry, jumped too fast… you want to know HOW to launch
see my PythonPrint module which launches a python script …
https://github.com/sdetweil/MMM-PythonPrintwell. actually its probably the first…
https://forum.magicmirror.builders/topic/16554/mmm-pythonprint-customisation/2?_=1648232499718the gesture node_helper does exec
so the same command you would do from the commandline…
but python has trouble with libraries when invoked in the background…
-
So after some thinkering with the hint I got, I’ve got the code working:
"UP": { shellExec: "python /home/pi/ws2801_inschakelen.py", }, "DOWN": { shellExec: "python /home/pi/ws2801_uitschakelen.py", }Thanks for the help!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login