MagicMirror Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • Donate
    • Discord

    MMM-GroveGestures -> ShellExec "Python script"

    Troubleshooting
    2
    3
    81
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Robert_K
      Robert_K last edited by Robert_K

      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

      S 1 Reply Last reply Reply Quote 0
      • S
        sdetweil @Robert_K last edited by sdetweil

        @Robert_K

        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-PythonPrint

        well. actually its probably the first…
        https://forum.magicmirror.builders/topic/16554/mmm-pythonprint-customisation/2?_=1648232499718

        the 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…

        Sam

        Create a working config
        How to add modules

        1 Reply Last reply Reply Quote 0
        • Robert_K
          Robert_K last edited by

          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!

          1 Reply Last reply Reply Quote 1
          • 1 / 1
          • First post
            Last post
          Enjoying MagicMirror? Please consider a donation!
          MagicMirror created by Michael Teeuw.
          Forum managed by Paul-Vincent Roll and Rodrigo Ramírez Norambuena.
          This forum is using NodeBB as its core | Contributors
          Contact | Privacy Policy