<?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[Help creating a shutdown button?]]></title><description><![CDATA[<p dir="auto">Hi, I am trying to add a button/switch to my mirror for safe shutdown. I am using RPi3 model B.</p>
<p dir="auto">I have this: <a href="https://www.amazon.com/gp/product/B0170B75EU/ref=oh_aui_detailpage_o00_s00?ie=UTF8&amp;psc=1" target="_blank" rel="noopener noreferrer nofollow ugc">https://www.amazon.com/gp/product/B0170B75EU/ref=oh_aui_detailpage_o00_s00?ie=UTF8&amp;psc=1</a></p>
<p dir="auto">The problem I am having is with adding the code to make it function as a shutdown button.</p>
<p dir="auto">Full disclosure: I know absolutely nothing about how to use python.</p>
<p dir="auto">Any help you can provide would be appreciated.</p>
]]></description><link>https://forum.magicmirror.builders/topic/936/help-creating-a-shutdown-button</link><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Apr 2026 13:18:19 GMT</lastBuildDate><atom:link href="https://forum.magicmirror.builders/topic/936.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 05 Nov 2016 23:15:59 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Help creating a shutdown button? on Mon, 07 Nov 2016 08:43:31 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/bez252" aria-label="Profile: bez252">@<bdi>bez252</bdi></a> Actually what they describe might also work for you, based on a quick glance through the setup code.</p>
<p dir="auto">To shutdown from the <code>node_helper</code> you need to change some code <a href="https://github.com/PtrBld/MMM-Button/blob/master/node_helper.js" target="_blank" rel="noopener noreferrer nofollow ugc">in the file</a>(will be in <code>MMM-Button/node_helper.js</code> in your file system).<br />
<a href="https://github.com/Jopyth/MMM-Remote-Control/blob/master/node_helper.js#L91" target="_blank" rel="noopener noreferrer nofollow ugc">Here</a> is an example from my module to shut down the RPi, you can replace the <code>self.sendSocketNotification(...)</code> in the <code>node_helper</code>  with a similar command:</p>
<pre><code class="language-javascript">exec('sudo shutdown -h now', null);
</code></pre>
<p dir="auto">Also, at the beginning of the file you need to include the <code>exec</code> function, like <a href="https://github.com/Jopyth/MMM-Remote-Control/blob/master/node_helper.js#L12" target="_blank" rel="noopener noreferrer nofollow ugc">here</a>:</p>
<pre><code class="language-javascript">const exec = require('child_process').exec;
</code></pre>
]]></description><link>https://forum.magicmirror.builders/post/7621</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/7621</guid><dc:creator><![CDATA[Jopyth]]></dc:creator><pubDate>Mon, 07 Nov 2016 08:43:31 GMT</pubDate></item><item><title><![CDATA[Reply to Help creating a shutdown button? on Mon, 07 Nov 2016 00:41:41 GMT]]></title><description><![CDATA[<p dir="auto">Also, would these instructions work with the button I have?: <a href="http://www.mausberrycircuits.com/pages/setup" target="_blank" rel="noopener noreferrer nofollow ugc">http://www.mausberrycircuits.com/pages/setup</a></p>
<p dir="auto">Or would they only work with the mausberry circuits buttons that attach to the power cord?</p>
]]></description><link>https://forum.magicmirror.builders/post/7618</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/7618</guid><dc:creator><![CDATA[bez252]]></dc:creator><pubDate>Mon, 07 Nov 2016 00:41:41 GMT</pubDate></item><item><title><![CDATA[Reply to Help creating a shutdown button? on Sun, 06 Nov 2016 22:22:05 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jopyth" aria-label="Profile: Jopyth">@<bdi>Jopyth</bdi></a> So, with the module you linked, would these default settings mean that it activates when pin 5 is grounded? I apologize for all these dumb questions. Iḿ really new to this entire scene. Also, what would I need to change to make it shutdown?</p>
<p dir="auto">´/* global Module */</p>
<p dir="auto">/* Magic Mirror</p>
<ul>
<li>Module: MMM-Button</li>
<li></li>
<li>MIT Licensed.<br />
*/</li>
</ul>
<p dir="auto">Module.register(‘MMM-Button’,{	<br />
defaults: {<br />
buttonPIN: 5,<br />
//time in miliseconds before another button click is recognized<br />
clickDelay: 500,		<br />
},	<br />
// Override socket notification handler.<br />
socketNotificationReceived: function(notification, payload) {<br />
if (notification === “BUTTON_PRESSED”){<br />
this.sendNotification(notification, payload)<br />
}<br />
},	<br />
start: function() {<br />
this.sendSocketNotification(‘BUTTON_CONFIG’, this.config);<br />
<a href="http://Log.info" target="_blank" rel="noopener noreferrer nofollow ugc">Log.info</a>('Starting module: ’ + <a href="http://this.name" target="_blank" rel="noopener noreferrer nofollow ugc">this.name</a>);<br />
}<br />
});´</p>
]]></description><link>https://forum.magicmirror.builders/post/7614</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/7614</guid><dc:creator><![CDATA[bez252]]></dc:creator><pubDate>Sun, 06 Nov 2016 22:22:05 GMT</pubDate></item><item><title><![CDATA[Reply to Help creating a shutdown button? on Sun, 06 Nov 2016 20:43:55 GMT]]></title><description><![CDATA[<p dir="auto">I got one of these for my mirror, still havn’t built or assembled it yet.</p>
<p dir="auto"><a href="https://www.pi-supply.com/product/pi-supply-raspberry-pi-power-switch/" target="_blank" rel="noopener noreferrer nofollow ugc">https://www.pi-supply.com/product/pi-supply-raspberry-pi-power-switch/</a></p>
]]></description><link>https://forum.magicmirror.builders/post/7610</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/7610</guid><dc:creator><![CDATA[pugsly]]></dc:creator><pubDate>Sun, 06 Nov 2016 20:43:55 GMT</pubDate></item><item><title><![CDATA[Reply to Help creating a shutdown button? on Sun, 06 Nov 2016 16:02:31 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jopyth" aria-label="Profile: Jopyth">@<bdi>Jopyth</bdi></a><br />
That would be awesome, thanks.</p>
]]></description><link>https://forum.magicmirror.builders/post/7601</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/7601</guid><dc:creator><![CDATA[bez252]]></dc:creator><pubDate>Sun, 06 Nov 2016 16:02:31 GMT</pubDate></item><item><title><![CDATA[Reply to Help creating a shutdown button? on Sun, 06 Nov 2016 14:25:26 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/bez252" aria-label="Profile: bez252">@<bdi>bez252</bdi></a> I made a module (acutally two) for this, however they are not (very well) documented and I just made them for myself. But if you want, I could upload them.</p>
<p dir="auto">I have four buttons conncted to the RPi, and one of them shuts down the system on a long press (&gt;3 seconds).</p>
<p dir="auto">There is also <a href="https://github.com/PtrBld/MMM-Button" target="_blank" rel="noopener noreferrer nofollow ugc">this module</a>, which you can adapt by adding a shutdown command.</p>
]]></description><link>https://forum.magicmirror.builders/post/7598</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/7598</guid><dc:creator><![CDATA[Jopyth]]></dc:creator><pubDate>Sun, 06 Nov 2016 14:25:26 GMT</pubDate></item></channel></rss>