• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
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.

Help creating a shutdown button?

Scheduled Pinned Locked Moved Troubleshooting
troubleshoothelpbuttonswitchshutdown
7 Posts 3 Posters 4.9k Views 3 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.
  • B Offline
    bez252 @Jopyth
    last edited by Nov 6, 2016, 4:02 PM

    @Jopyth
    That would be awesome, thanks.

    1 Reply Last reply Reply Quote 0
    • P Offline
      pugsly
      last edited by Nov 6, 2016, 8:43 PM

      I got one of these for my mirror, still havn’t built or assembled it yet.

      https://www.pi-supply.com/product/pi-supply-raspberry-pi-power-switch/

      1 Reply Last reply Reply Quote 0
      • B Offline
        bez252 @Jopyth
        last edited by bez252 Nov 6, 2016, 10:22 PM Nov 6, 2016, 10:21 PM

        @Jopyth 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?

        ´/* global Module */

        /* Magic Mirror

        • Module: MMM-Button
        • MIT Licensed.
          */

        Module.register(‘MMM-Button’,{
        defaults: {
        buttonPIN: 5,
        //time in miliseconds before another button click is recognized
        clickDelay: 500,
        },
        // Override socket notification handler.
        socketNotificationReceived: function(notification, payload) {
        if (notification === “BUTTON_PRESSED”){
        this.sendNotification(notification, payload)
        }
        },
        start: function() {
        this.sendSocketNotification(‘BUTTON_CONFIG’, this.config);
        Log.info('Starting module: ’ + this.name);
        }
        });´

        1 Reply Last reply Reply Quote 0
        • B Offline
          bez252
          last edited by Nov 7, 2016, 12:41 AM

          Also, would these instructions work with the button I have?: http://www.mausberrycircuits.com/pages/setup

          Or would they only work with the mausberry circuits buttons that attach to the power cord?

          J 1 Reply Last reply Nov 7, 2016, 8:42 AM Reply Quote 0
          • J Offline
            Jopyth Moderator @bez252
            last edited by Jopyth Nov 7, 2016, 8:43 AM Nov 7, 2016, 8:42 AM

            @bez252 Actually what they describe might also work for you, based on a quick glance through the setup code.

            To shutdown from the node_helper you need to change some code in the file(will be in MMM-Button/node_helper.js in your file system).
            Here is an example from my module to shut down the RPi, you can replace the self.sendSocketNotification(...) in the node_helper with a similar command:

            exec('sudo shutdown -h now', null);
            

            Also, at the beginning of the file you need to include the exec function, like here:

            const exec = require('child_process').exec;
            

            Helpful sticky: How to troubleshoot

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            1 / 1
            • First post
              7/7
              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