bugsounet / MMM-Pir

Manage your screen with a pir sensor
MIT License
31 stars 8 forks source link

MMM-Pir

After a configured time without any user interaction the display will turn off and hide all modules for economy mode.
It will wake up with a Pir sensor or Touch screen

Screenshot

Installation

Minimal node version requirement: v20

Clone the module into your MagicMirror module folder and execute npm install in the module's directory.

cd ~/MagicMirror/modules
git clone https://github.com/bugsounet/MMM-Pir
cd MMM-Pir
npm install

This module will verify if all screen saver is disabled and disable it if needed

Configuration

To display the module insert it in the config.js file.

Personalized configuration

{
  module: 'MMM-Pir',
  position: 'top_left',
  config: {
    debug: false,
    delay: 2 * 60 * 1000,
    mode: 1,
    displayCounter: true,
    displayBar: true,
    displayStyle: "Text",
    displayLastPresence: true,
    lastPresenceTimeFormat: "LL H:mm",
    mode6_gpio: 20,
    mode6_clearGpioValue: true,
    xrandrForceRotation: "normal",
    wrandrForceRotation: "normal",
    wrandrForceMode: "1920x1080",
    touchMode: 3,
    pir_gpio: 21,
    pir_mode: 0,
  }
},

Detailed Configuration

Option Description Type Default
debug enable or not debug mode Boolean false
delay Time before the mirror turns off the display if no user activity is detected. (in ms) Number 120000
mode mode for turn on/off your screen (see bellow) number
displayCounter Should display Count-down in screen ? Boolean true
displayBar Should display Count-up bar in screen ? Boolean true
displayStyle Style of the Count-down. Available: "Text", "Line", "SemiCircle", "Circle" String Text
displayLastPresence Display the date of the last user presence  Boolean true
lastPresenceTimeFormat Change the date format (moment.js format) of the last presence String LL H:mm
mode6_gpio -mode 6 only- GPIO number for control the relay (switch) Number 20
mode6_clearGpioValue -mode 6 only- reset GPIO value script of relay (switch) Boolean true 
xrandrForceRotation -mode 9 only- Forces screen rotation according to the defined value (possible value: "normal", "left", "right", "inverted") String normal
wrandrForceRotation -mode 10 only- Forces screen rotation according to the defined value (possible value: "normal", "90", "180", "270", "flipped", "flipped-90", "flipped-180", "flipped-270") String normal
wrandrForceMode -mode 10 only- Force screen resolution mode String null
touchMode Selected mode for enable/disable the screen with touch (see below) Number 3
pir_gpio BCM-number of the sensor pin. Use 0, if you want to disable PIR Sensor detection Number 21
pir_mode Detection mode (see bellow) Number 0

Developer Notes

Update

Manual update

In a terminal try this command:

cd ~/MagicMirror/modules/MMM-Pir
npm run update

Automatic Update from updatenotification default module

Since MagicMirror² v2.27.x, we are able to Update automaticaly any modules from updatenotification.
Let's add MMM-Pir rule

  {
    module: "updatenotification",
    position: "top_center",
    config: {
      updateAutorestart: true, // restart MagicMirror automaticaly after update
      updates: [
        // MMM-Pir rule
        {
          "MMM-Pir": "npm run update"
        },
      ]
    }
  },

Reinstall

For reinstall this module or when an update of MagicMirror² is available, you can use this command:

cd ~/MagicMirror/modules/MMM-Pir
npm run rebuild

Notes

Support