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: "Welcome back" message

    Scheduled Pinned Locked Moved Troubleshooting
    2 Posts 2 Posters 1.7k Views 2 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.
    • D Offline
      deWizard
      last edited by

      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. :)

      1 Reply Last reply Reply Quote 0
      • D Offline
        doubleT Module Developer
        last edited by

        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(() => {
                    this.removeMessage();
                }, (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.

        1 Reply Last reply Reply Quote 3
        • 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