<?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 js error]]></title><description><![CDATA[<p dir="auto">Here is error log:</p>
<pre><code>0|run-star | [17.11.2021 14:03.06.696] [ERROR] Whoops! There was an uncaught exception...
0|run-star | [17.11.2021 14:03.06.782] [ERROR] TypeError: Cannot read property 'callbackScripts' of undefined
0|run-star |     at Class.socketNotificationReceived (/home/pi/MagicMirror/modules/MMM-PIR/node_helper.js:37:45)
0|run-star |     at Socket.socket.on (/home/pi/MagicMirror/js/node_helper.js:109:11)
0|run-star |     at Socket.emit (events.js:198:13)
0|run-star |     at Socket.emitUntyped (/home/pi/MagicMirror/node_modules/socket.io/dist/typed-events.js:69:22)
0|run-star |     at process.nextTick (/home/pi/MagicMirror/node_modules/socket.io/dist/socket.js:428:39)
0|run-star |     at process._tickCallback (internal/process/next_tick.js:61:11)
</code></pre>
<p dir="auto">Here is my node_helper.js</p>
<pre><code>var NodeHelper = require("node_helper");
const exec = require('child_process').exec;
const fs = require('fs');
const Gpio = require('onoff').Gpio;

var commandDict = {
    "js": "node",
    "py": "python",
    "sh": "sh"
};

module.exports = NodeHelper.create({

    running: false,

    socketNotificationReceived: function (notification, payload) {
        const self = this;
        if (notification === "CONFIG") {
            this.config = payload;
            this.pir = new Gpio(this.config.sensorPin, 'in', 'both');

            this.pir.watch(function (err, value) {
                if (value == 1) {
                    self.sendSocketNotification("USER_PRESENCE", true);
                    if (!self.running) {
                        self.running = true;
                        if (self.config.turnOffDisplay) {
                            execute(buildCommand("/default/ac.py"), function (stdout) {
                                console.log(stdout);
                            });
                        }
                    }
                }
            });
        } else if (notification === "TIMER_EXPIRED") {
            self.running = false;
            for (var i = 0; i &lt; this.config.callbackScripts.length; i++) {
                execute(buildCommand(this.config.callbackScripts[i]), function (stdout) {
                    console.log(stdout);
                });
            }
            if (self.config.turnOffDisplay) {
                execute(buildCommand("/default/kapat.py"), function (stdout) {
                    console.log(stdout);
                });
            }
        }
    },


});

function buildCommand(fileName) {
    var file = __dirname + "/callbackScripts/" + fileName;
    var fileExtension = file.split(".").slice(-1).pop();
    return commandDict[fileExtension] + " " + file;
}

function execute(command, callback) {
    exec(command, function (error, stdout, stderr) {
        if (error) {
            console.log(stderr);
        } else {
            callback(stdout);
        }
    });
}

</code></pre>
]]></description><link>https://forum.magicmirror.builders/topic/16040/mmm-pir-js-error</link><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Jul 2026 20:07:35 GMT</lastBuildDate><atom:link href="https://forum.magicmirror.builders/topic/16040.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 19 Dec 2021 21:22:31 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to MMM-PIR js error on Mon, 20 Dec 2021 20:51:58 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/uok825" aria-label="Profile: uok825">@<bdi>uok825</bdi></a> Anyone can help? <a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a> maybe</p>
]]></description><link>https://forum.magicmirror.builders/post/97664</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/97664</guid><dc:creator><![CDATA[uok825]]></dc:creator><pubDate>Mon, 20 Dec 2021 20:51:58 GMT</pubDate></item></channel></rss>