MMM-NewPIR is a module for the MagicMirror project by Michael Teeuw.
It uses a PIR sensor attached to your raspberry pi's GPIO pins to check for users. After a configurated time without any user interaction the display will turn off and hide all module for economy mode.
If you don't have PIR sensor, it can also be used for automatic turn on / turn off screen.
- Rewrite entire main code
- New configuration
- Use my own shared npm library
- Add new display style
- More tools: incomming notification for developers
- New support for turn off screen !
- New scripts for updating
- Touch Screen support
Needed: MagicMirror v2.13.0 and above
Clone the module into your MagicMirror module folder and execute npm intall
in the module's directory.
cd ~/MagicMirror/modules
git clone https://github.com/guicrepin/MMM-NewPIR.git
cd MMM-NewPIR
npm install
This module will verify if all screen saver is disabled and disable it if needed
To display the module insert it in the config.js file. Here is an example:
{
module: 'MMM-NewPIR',
position: 'top_left',
configDeepMerge: true,
config: {
screen: {
delay: 2 * 60 * 1000
},
pir: {
gpio: 21
},
}
},
this is the default configuration defined if you don't define any value
{
module: 'MMM-NewPIR',
position: 'top_left',
configDeepMerge: true,
config: {
debug: false,
screen: {
delay: 2 * 60 * 1000,
turnOffDisplay: true,
mode: 1,
ecoMode: true,
displayCounter: true,
text: "Auto Turn Off Screen:",
displayBar: true,
displayStyle: "Text",
governorSleeping: false,
displayLastPresence: true,
LastPresenceText: "Last Presence:",
useTouch: false
},
pir: {
usePir: true,
gpio: 21,
reverseValue: false
},
governor: {
useGovernor: false,
sleeping: "powersave",
working: "ondemand"
}
}
},
Option | Description | Type | Default |
---|---|---|---|
delay | Time before the mirror turns off the display if no user activity is detected. (in ms) | Number | 120000 |
turnOffDisplay | Should the display turn off after timeout? | Boolean | true |
mode | mode for turn on/off your screen (see bellow) | number | 1 |
ecoMode | Should the MagicMirror hide all module after timeout ? | Boolean | true |
displayCounter | Should display Count-down in screen ? | Boolean | true |
text | Display a text near the counter | String | "Auto Turn Off Screen:" |
displayBar | Should display Count-up bar in screen ? | Boolean | true |
displayStyle | Style of the Count-down. Available: "Text", "Line", "SemiCircle", "Circle", "Bar" | String | Text |
governorSleeping | Activate sleeping governor when screen is off | Boolean | false |
displayLastPresence | Display the date of the last user presence | Boolean | true |
LastPresenceText | Display this text near the last presence date | Text | Last Presence: |
useTouch | Allow to use TouchScreen or mouse (see TouchScreen Field below) | Boolean | false |
- Available mode:
mode: 1
- use vgencmd (RPI only)mode: 2
- use dpms (version RPI)mode: 3
- use tvservice (RPI only)mode: 4
- use HDMI CECmode: 5
- use dpms (linux version for debian, ubuntu, ...)
Note: the mode 0 disable turnOffDisplay too
Option | Description | Type | Default |
---|---|---|---|
usePir | activation of Pir sensor module | Boolean | true |
gpio | BCM-number of the sensor pin | Number | 21 |
reverseValue | presence detector value | Boolean | false |
Option | Description | Type | Default |
---|---|---|---|
useGovernor | When you set to true, you enable governor management | Boolean | true |
sleeping | name of the governor when screen is in sleeping state | String | powersave |
working | name of the governor when screen is actived | String | ondemand |
Available governor:
- conservative
- ondemand
- userspace
- powersave
- performance
Notes: On boot of your RPI, your governor is reset automaticaly to ondemand
- This module broadcasts:
USER_PRESENCE
notification with the payload beeingtrue
orfalse
you can use it to pause or disable another module.
- This module receive:
USER_PRESENCE
notification with the payloadtrue
to force user presence orfalse
to force delay to time out.SCREEN_END
notification to force the end of the count downSCREEN_WAKEUP
notification to wake up the screen and reset count downSCREEN_LOCK
notification keep the screen on and lock it (freeze counter and stop pir detection)SCREEN_UNLOCK
notification unlock the screen and restart counter and pir detection
cd ~/MagicMirror/modules/MMM-NewPIR
git pull
npm run update
You can use this feature with a mouse or your touch screen
- One Click on the NewPIR Area: will restart your shutdown timer
- Long Click on the screen: Will turn off your screen or Will turn on if needed (Toogle)
Donate, if you love this module !
- Review Touch Screen Feature
- add TouchScreen Feature
- add new supprt for turn on/off screen
- add npm checker
- add last presence
- del configMerge and take place to MM integred version
- Add: config merge script
- V3 initial commit
- Rewrite code