<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[MMM-PIR-Sensor execute .py script]]></title><description><![CDATA[<p dir="auto"><strong>Goal</strong>: Execute .py using MMM-Pir-Sensor</p>
<p dir="auto">Hi all, I’m having trouble executing a .py script that sits in the directory:</p>
<p dir="auto"><code>/home/pi/Documents/test.py</code></p>
<p dir="auto">According to <a class="plugin-mentions-user plugin-mentions-a" href="/user/orayoflighto" aria-label="Profile: orayoflighto">@<bdi>orayoflighto</bdi></a> in <a href="https://forum.magicmirror.builders/topic/4649/led-backlight-for-mirror-pir-to-control-them/5">this thread</a>, he suggests adding 1 line to <strong>node_helper.js</strong> that sits in the MMM-PIR-Sensor module directory from:</p>
<pre><code>        if (data.indexOf("0x120002") !== -1)
          exec("/opt/vc/bin/tvservice --preferred &amp;&amp; chvt 6 &amp;&amp; chvt 7", null);
</code></pre>
<p dir="auto">to</p>
<pre><code>        if (data.indexOf("0x120002") !== -1){
          exec("/opt/vc/bin/tvservice --preferred &amp;&amp; chvt 6 &amp;&amp; chvt 7", null);
          exec("python /home/pi/py-spidev/RPi-LPD8806/LED.py");
       }
</code></pre>
<p dir="auto"><strong>I’ve tried this exec() below in both activateMonitor and briefHDMIWakeup function and it’s not working.</strong></p>
<pre><code>    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")
</code></pre>
<p dir="auto">Note, calling sudo python3 <a href="http://test.py" target="_blank" rel="noopener noreferrer nofollow ugc">test.py</a> in cmd line works itself. <strong>I’m having trouble figuring out why exec() is not calling in node_helper.js. Any tips on debugging this?</strong></p>
<p dir="auto">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)</p>
<p dir="auto">Thanks for reading!</p>
]]></description><link>https://forum.magicmirror.builders/topic/13991/mmm-pir-sensor-execute-py-script</link><generator>RSS for Node</generator><lastBuildDate>Fri, 08 May 2026 14:32:26 GMT</lastBuildDate><atom:link href="https://forum.magicmirror.builders/topic/13991.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 06 Nov 2020 21:09:11 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to MMM-PIR-Sensor execute .py script on Fri, 06 Nov 2020 21:25:42 GMT]]></title><description><![CDATA[<p dir="auto">MMM-PIR-Sensor by paviro node_helper.js txt <a href="https://github.com/paviro/MMM-PIR-Sensor/blob/master/node_helper.js" target="_blank" rel="noopener noreferrer nofollow ugc">here</a></p>
]]></description><link>https://forum.magicmirror.builders/post/84361</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/84361</guid><dc:creator><![CDATA[bkost]]></dc:creator><pubDate>Fri, 06 Nov 2020 21:25:42 GMT</pubDate></item></channel></rss>