Read the statement by Michael Teeuw here.
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(() => { 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.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login