MMM-PIR-Sensor: "Welcome back" message

  • Hi there,

    I’m completely new to all of this but still want to give it a try.
    I’ve intergrated the MMM-PIR-Sensor module to my MagicMirror and it’s working just fine.

    The Issue I’m now facing is that I want to display a “Welcome back!” message when the monitor is reactivated. I’ve tried some things but none of them worked at all.

    Anyone to help me out with that - it would be very appreciated. :)

  • I don’t have a PIR to test, but looking at the code, I’d suggest trying something like this:

    You need a DOM element to show the message in. You can borrow it from the default module helloworld and modify it:

    getDom: function() {
        var wrapper = document.createElement("div");
        wrapper.setAttribute("id", "welcome-message");
        wrapper.innerHTML = "";
        return wrapper;

    And then, based on self.sendSocketNotification("USER_PRESENCE", true); in the node_helper.js you add
    this to the MMM-PIR-Sensor.js :

    socketNotificationReceived: function(notification, payload) {
        if (notification === "USER_PRESENCE"){
            this.sendNotification(notification, payload)
    //  new:
            if (payload === true) {
            document.getElementById("welcome-message").innerHTML = "Welcome back!";
            setTimeout(() => {
            }, (1*60*1000); // = 60 seconds
    removeMessage: function(payload) {
        document.getElementById("welcome-message").innerHTML = "";

    If you use it like this, the message is only shown for 1 * 60 * 1000 miliseconds = 60 seconds (set as desired) and then removed.

    This is all untested but hopefully gives you some clues where to look and work on the code.

Log in to reply

Looks like your connection to MagicMirror Forum was lost, please wait while we try to reconnect.