• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
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 305 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 Nov 6, 2020, 9:09 PM

    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 Nov 6, 2020, 9:25 PM

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

      1 Reply Last reply Reply Quote 0
      • 1 / 1
      1 / 1
      • First post
        1/2
        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