MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    MMM-PIR-Sensor execute .py script

    Scheduled Pinned Locked Moved Troubleshooting
    2 Posts 1 Posters 471 Views 1 Watching
    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.
    • B Offline
      bkost
      last edited by

      Goal: Execute .py using MMM-Pir-Sensor

      Hi all, I’m having trouble executing a .py script that sits in the directory:

      /home/pi/Documents/test.py

      According to @orayoflighto in this thread, he suggests adding 1 line to node_helper.js that sits in the MMM-PIR-Sensor module directory from:

              if (data.indexOf("0x120002") !== -1)
                exec("/opt/vc/bin/tvservice --preferred && chvt 6 && chvt 7", null);
      

      to

              if (data.indexOf("0x120002") !== -1){
                exec("/opt/vc/bin/tvservice --preferred && chvt 6 && chvt 7", null);
                exec("python /home/pi/py-spidev/RPi-LPD8806/LED.py");
             }
      

      I’ve tried this exec() below in both activateMonitor and briefHDMIWakeup function and it’s not working.

          briefHDMIWakeup: function() {
              const self = this
              exec("/usr/bin/vcgencmd display_power").stdout.on('data', function(data) {
                  if (data.indexOf("display_power=0") === 0) {
                      exec("/usr/bin/vcgencmd display_power 1", null);
                      exec("python /home/pi/Documents/test.py")
      

      Note, calling sudo python3 test.py in cmd line works itself. I’m having trouble figuring out why exec() is not calling in node_helper.js. Any tips on debugging this?

      I tried console.log(text); in .js file. It’s not calling either (i may be totally viewing command prompt wrong to view debug message)

      Thanks for reading!

      1 Reply Last reply Reply Quote 0
      • B Offline
        bkost
        last edited by

        MMM-PIR-Sensor by paviro node_helper.js txt here

        1 Reply Last reply Reply Quote 0

        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
        • 1 / 1
        • First post
          Last post
        Enjoying MagicMirror? Please consider a donation!
        MagicMirror created by Michael Teeuw.
        Forum managed by Sam, technical setup by Karsten.
        This forum is using NodeBB as its core | Contributors
        Contact | Privacy Policy