<?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[Send existing Notifications from a script]]></title><description><![CDATA[<p dir="auto">Hey :)<br />
I want to re-write the “MMM-SmartTouch” Module to have an “App-Dock-Bar”. I was able to change the CSS file to have this look now:</p>
<p dir="auto"><img src="/assets/uploads/files/1593386260852-neu1.jpg" alt="neu1.JPG" class=" img-fluid img-markdown" /></p>
<p dir="auto">I also was able to add the first 4 buttons with costom icons. I want to have these icons to change the pages with “MMM-pages”.<br />
The pages module listens on these Notifications: PAGE_CHANGED, pageNumber</p>
<p dir="auto">But I cant get it to work. This is my smartTouch.js and my nodeHelper:</p>
<p dir="auto">MMM-smartTouch.js :</p>
<pre><code>//Main Menu Bar
        var main_menu = document.createElement("div");
        main_menu.className = "main-menu"
        main_menu.id = "navbar"
        home_div.appendChild(main_menu)
        var main_menu_ul = document.createElement("ul");
        main_menu_ul.className = "navbar-nav"
        main_menu.appendChild(main_menu_ul)

	//Page 1 (Home Screen)
        var main_menu_li_restart = document.createElement("span");
        main_menu_li_restart.innerHTML = "&lt;span class='fas fa-home fa-3x'&gt;&lt;/span&gt;" + "&amp;nbsp" + "&amp;nbsp" + "&amp;nbsp" + "&amp;nbsp";
        main_menu_li_restart.className = "li-t"
        main_menu_ul.appendChild(main_menu_li_restart)
        main_menu_li_restart.addEventListener("click", () =&gt; this.sendSocketNotification("PAGEONE", {}));

	//Page 2 (Wetter)
        var main_menu_li_restart = document.createElement("span");
        main_menu_li_restart.innerHTML = "&lt;span class='fas fa-cloud-sun fa-3x'&gt;&lt;/span&gt;" + "&amp;nbsp" + "&amp;nbsp" + "&amp;nbsp" + "&amp;nbsp";
        main_menu_li_restart.className = "li-t"
        main_menu_ul.appendChild(main_menu_li_restart)
        main_menu_li_restart.addEventListener("click", () =&gt; this.sendSocketNotification("SHUTDOWN", {}));

	//Page 3 (Drive Bilder)
        var main_menu_li_restart = document.createElement("span");
        main_menu_li_restart.innerHTML = "&lt;span class='far fa-image fa-3x'&gt;&lt;/span&gt;" + "&amp;nbsp" + "&amp;nbsp" + "&amp;nbsp" + "&amp;nbsp";
        main_menu_li_restart.className = "li-t"
        main_menu_ul.appendChild(main_menu_li_restart)
        main_menu_li_restart.addEventListener("click", () =&gt; this.sendSocketNotification("SHUTDOWN", {}));

	//Page 4 (Party Bilder)
        var main_menu_li_restart = document.createElement("span");
        main_menu_li_restart.innerHTML = "&lt;span class='far fa-image fa-3x'&gt;&lt;/span&gt;" + "&amp;nbsp" + "&amp;nbsp" + "&amp;nbsp" + "&amp;nbsp";
        main_menu_li_restart.className = "li-t"
        main_menu_ul.appendChild(main_menu_li_restart)
        main_menu_li_restart.addEventListener("click", () =&gt; this.sendSocketNotification("SHUTDOWN", {}));
        
        //Power Off Button
        var main_menu_li_shutdown = document.createElement("span");
        main_menu_li_shutdown.innerHTML = "&lt;span class='fa fa-power-off fa-3x'&gt;&lt;/span&gt;" + "&amp;nbsp" + "&amp;nbsp" + "&amp;nbsp" + "&amp;nbsp";
        main_menu_li_shutdown.className = "li-t"
        main_menu_ul.appendChild(main_menu_li_shutdown)

        //Onclick event to send shutdown notification
        main_menu_li_shutdown.addEventListener("click", () =&gt; this.sendSocketNotification("SHUTDOWN", {}));

        //Restart Button
        var main_menu_li_restart = document.createElement("span");
        main_menu_li_restart.innerHTML = "&lt;span class='fa fa-repeat fa-3x'&gt;&lt;/span&gt;" + "&amp;nbsp" + "&amp;nbsp" + "&amp;nbsp" + "&amp;nbsp";
        main_menu_li_restart.className = "li-t"
        main_menu_ul.appendChild(main_menu_li_restart)
        main_menu_li_restart.addEventListener("click", () =&gt; this.sendSocketNotification("RESTART", {}));

</code></pre>
<p dir="auto">and my nodeHelper.js:</p>
<pre><code>if (notification === "PAGEONE") {
              console.log("Page1!")
              require('child_process').this.sendSocketNotification("PAGE_CHANGED", 1);
          }

	  if (notification === "SHUTDOWN") {
              console.log("Shutting Down!")
              require('child_process').exec('shutdown -h now', console.log)
          }

          if (notification === "RESTART") {
              console.log("Restarting Magic Mirror!")
              require('child_process').exec('sudo reboot', console.log)
          }
</code></pre>
<p dir="auto">nothing happens when i touch the first (Page1) icon…</p>
<p dir="auto">Thx for help! :) Toby</p>
]]></description><link>https://forum.magicmirror.builders/topic/13159/send-existing-notifications-from-a-script</link><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Apr 2026 09:38:09 GMT</lastBuildDate><atom:link href="https://forum.magicmirror.builders/topic/13159.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 28 Jun 2020 23:24:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Send existing Notifications from a script on Tue, 30 Jun 2020 00:29:14 GMT]]></title><description><![CDATA[<p dir="auto">It‘s working! Thx u!!</p>
]]></description><link>https://forum.magicmirror.builders/post/77838</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/77838</guid><dc:creator><![CDATA[thetobyde]]></dc:creator><pubDate>Tue, 30 Jun 2020 00:29:14 GMT</pubDate></item><item><title><![CDATA[Reply to Send existing Notifications from a script on Mon, 29 Jun 2020 10:46:00 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a> sorry read thorugh it too fast</p>
]]></description><link>https://forum.magicmirror.builders/post/77813</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/77813</guid><dc:creator><![CDATA[lavolp3]]></dc:creator><pubDate>Mon, 29 Jun 2020 10:46:00 GMT</pubDate></item><item><title><![CDATA[Reply to Send existing Notifications from a script on Mon, 29 Jun 2020 10:38:14 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/lavolp3" aria-label="Profile: lavolp3">@<bdi>lavolp3</bdi></a> which is what I said 3 posts back</p>
]]></description><link>https://forum.magicmirror.builders/post/77812</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/77812</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Mon, 29 Jun 2020 10:38:14 GMT</pubDate></item><item><title><![CDATA[Reply to Send existing Notifications from a script on Mon, 29 Jun 2020 07:32:09 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/thetobyde" aria-label="Profile: thetobyde">@<bdi>thetobyde</bdi></a> I think you should avoid the node_helper and directly send a broadcast notification via <code>self.sendNotification()</code> to to the MMM-pages module.</p>
<pre><code>      button.addEventListener("click", function() {
        self.sendNotification("PAGE_CHANGED", i);
      });
</code></pre>
]]></description><link>https://forum.magicmirror.builders/post/77801</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/77801</guid><dc:creator><![CDATA[lavolp3]]></dc:creator><pubDate>Mon, 29 Jun 2020 07:32:09 GMT</pubDate></item><item><title><![CDATA[Reply to Send existing Notifications from a script on Mon, 29 Jun 2020 07:30:10 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/thetobyde" aria-label="Profile: thetobyde">@<bdi>thetobyde</bdi></a> if you haven’t figured it out yet, have a look at my module <a href="https://github.com/lavolp3/MMM-NavigationBar" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/lavolp3/MMM-NavigationBar</a> which kind of does what you want. This one is using MMM-pages as well.</p>
<p dir="auto">ALl that I needed for this to work out is this:</p>
<pre><code>  getDom: function() {
    var container = document.createElement("div");
    container.className = "naviContainer";
    self = this;
    for (var i = 0; i &lt; this.config.sections.length; i++) {
      var buttonDiv = document.createElement("div");
      buttonDiv.className = "naviButton fas fa-"+this.config.sectionIcons[this.config.sections[i]];
      buttonDiv.style.fontSize = this.config.iconSize + "px";
      button.addEventListener("click", function() {
        self.sendNotification("PAGE_CHANGED", i);
      });
      //this.log(buttonDiv.className);
      container.appendChild(buttonDiv);
    }
    return container;
  },
</code></pre>
]]></description><link>https://forum.magicmirror.builders/post/77800</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/77800</guid><dc:creator><![CDATA[lavolp3]]></dc:creator><pubDate>Mon, 29 Jun 2020 07:30:10 GMT</pubDate></item><item><title><![CDATA[Reply to Send existing Notifications from a script on Mon, 29 Jun 2020 02:04:12 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/thetobyde" aria-label="Profile: thetobyde">@<bdi>thetobyde</bdi></a> said in <a href="/post/77783">Send existing Notifications from a script</a>:</p>
<blockquote>
<pre><code>require('child_process').this.sendSocketNotification("PAGE_CHANGED", 1);
</code></pre>
</blockquote>
<p dir="auto">well, you are not launching a program to chnage the page, and don’t need to send this down to the node_helper<br />
as he has to send it back up to the module to send the notfication,</p>
<p dir="auto">just do the sendNotification from the module (note its not sendsocketNotification(to my node helper) , just sendNotification(to other modules)</p>
]]></description><link>https://forum.magicmirror.builders/post/77793</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/77793</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Mon, 29 Jun 2020 02:04:12 GMT</pubDate></item><item><title><![CDATA[Reply to Send existing Notifications from a script on Mon, 29 Jun 2020 01:59:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a> didt change that because it worked for the pre-existing Shutdown and Reboot button from the developer of MMM-smartTouch… isnt it right?</p>
]]></description><link>https://forum.magicmirror.builders/post/77792</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/77792</guid><dc:creator><![CDATA[thetobyde]]></dc:creator><pubDate>Mon, 29 Jun 2020 01:59:44 GMT</pubDate></item><item><title><![CDATA[Reply to Send existing Notifications from a script on Mon, 29 Jun 2020 00:52:49 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/thetobyde" aria-label="Profile: thetobyde">@<bdi>thetobyde</bdi></a> and the module code with the buttons?</p>
]]></description><link>https://forum.magicmirror.builders/post/77791</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/77791</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Mon, 29 Jun 2020 00:52:49 GMT</pubDate></item><item><title><![CDATA[Reply to Send existing Notifications from a script on Mon, 29 Jun 2020 00:14:34 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a><br />
<img src="https://ibb.co/cJtrKVj" alt="meinCode" class=" img-fluid img-markdown" /></p>
<p dir="auto">Like this :)</p>
]]></description><link>https://forum.magicmirror.builders/post/77790</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/77790</guid><dc:creator><![CDATA[thetobyde]]></dc:creator><pubDate>Mon, 29 Jun 2020 00:14:34 GMT</pubDate></item><item><title><![CDATA[Reply to Send existing Notifications from a script on Mon, 29 Jun 2020 00:07:12 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a> i changed the code in the nodeHelper from this. to self.</p>
]]></description><link>https://forum.magicmirror.builders/post/77789</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/77789</guid><dc:creator><![CDATA[thetobyde]]></dc:creator><pubDate>Mon, 29 Jun 2020 00:07:12 GMT</pubDate></item><item><title><![CDATA[Reply to Send existing Notifications from a script on Mon, 29 Jun 2020 00:00:40 GMT]]></title><description><![CDATA[<p dir="auto">u changed the code here from this. to self.<br />
=&gt; this.sendSocketNotification("SHUTDOWN<br />
and all similar</p>
]]></description><link>https://forum.magicmirror.builders/post/77788</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/77788</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Mon, 29 Jun 2020 00:00:40 GMT</pubDate></item><item><title><![CDATA[Reply to Send existing Notifications from a script on Sun, 28 Jun 2020 23:59:11 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/thetobyde" aria-label="Profile: thetobyde">@<bdi>thetobyde</bdi></a> did step thru the code w the developers window source tab?</p>
]]></description><link>https://forum.magicmirror.builders/post/77787</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/77787</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Sun, 28 Jun 2020 23:59:11 GMT</pubDate></item><item><title><![CDATA[Reply to Send existing Notifications from a script on Sun, 28 Jun 2020 23:50:58 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a> thx for the fast answer. I change „this.send…“ to „self.send…“ but did not work sadly… i also changed the payload from 1 to 0, because the notifications from MMM-pages are zero-based. So page 1 is PAGE_CHANGED, 0…</p>
<p dir="auto">The var self = this is written by the Developer of MMM-SmartTouch</p>
]]></description><link>https://forum.magicmirror.builders/post/77786</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/77786</guid><dc:creator><![CDATA[thetobyde]]></dc:creator><pubDate>Sun, 28 Jun 2020 23:50:58 GMT</pubDate></item><item><title><![CDATA[Reply to Send existing Notifications from a script on Sun, 28 Jun 2020 23:34:54 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/thetobyde" aria-label="Profile: thetobyde">@<bdi>thetobyde</bdi></a> in your click handlers, ‘this’ points to the button causing the click.</p>
<p dir="auto">this is why we do<br />
var self=this<br />
and use self. in handlers and callbacks<br />
instead of this.</p>
<p dir="auto">you should see the error reported in the developers window console</p>
]]></description><link>https://forum.magicmirror.builders/post/77784</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/77784</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Sun, 28 Jun 2020 23:34:54 GMT</pubDate></item></channel></rss>