{"id":13830605,"url":"https://github.com/paviro/MMM-PIR-Sensor","last_synced_at":"2025-07-09T12:30:29.225Z","repository":{"id":42480009,"uuid":"58231755","full_name":"paviro/MMM-PIR-Sensor","owner":"paviro","description":"This module can monitor a PIR motion sensor and put your mirror to sleep.","archived":true,"fork":false,"pushed_at":"2023-09-04T13:07:53.000Z","size":85,"stargazers_count":218,"open_issues_count":62,"forks_count":96,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-07-07T00:58:15.087Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paviro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-05-06T19:59:11.000Z","updated_at":"2025-04-08T13:06:25.000Z","dependencies_parsed_at":"2024-01-15T17:39:14.784Z","dependency_job_id":"f2e13bcf-3849-4245-8bad-85dfba576877","html_url":"https://github.com/paviro/MMM-PIR-Sensor","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/paviro/MMM-PIR-Sensor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paviro%2FMMM-PIR-Sensor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paviro%2FMMM-PIR-Sensor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paviro%2FMMM-PIR-Sensor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paviro%2FMMM-PIR-Sensor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paviro","download_url":"https://codeload.github.com/paviro/MMM-PIR-Sensor/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paviro%2FMMM-PIR-Sensor/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264458047,"owners_count":23611473,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T10:01:02.892Z","updated_at":"2025-07-09T12:30:28.941Z","avatar_url":"https://github.com/paviro.png","language":"JavaScript","funding_links":[],"categories":["Hardware"],"sub_categories":[],"readme":"# MMM-PIR-Sensor\nThis an extension for the [MagicMirror](https://github.com/MichMich/MagicMirror). It can monitor a [PIR motion](http://www.amazon.com/2013newestseller-HC-SR501-Pyroelectric-Infrared-Detector/dp/B00FDPO9B8) sensor and put your mirror to sleep if nobody uses it by turning off HDMI output or by turning off the mirror via a relay.\n\n## Installation\n1. Navigate into your MagicMirror's `modules` folder and execute `git clone https://github.com/paviro/MMM-PIR-Sensor.git`. A new folder will appear navigate into it.\n2. Execute `npm install` to install the node dependencies.\n3. Add your user (`pi`?) to the `gpio group` by executing `sudo usermod -a -G gpio pi`.\n4. Execute `sudo chmod u+s /opt/vc/bin/tvservice \u0026\u0026 sudo chmod u+s /bin/chvt` to allow turning on/off the hdmi output.\n5. Reboot your Pi.\n\n## Using the module\n\nTo use this module, add it to the modules array in the `config/config.js` file:\n````javascript\nmodules: [\n\t{\n\t\tmodule: 'MMM-PIR-Sensor',\n\t\tconfig: {\n\t\t\t// See 'Configuration options' for more information.\n\t\t}\n\t}\n]\n````\n\n## Configuration Options\n\nThe following properties can be configured:\n\n\u003ctable width=\"100%\"\u003e\n\t\u003c!-- why, markdown... --\u003e\n\t\u003cthead\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003cth\u003eOption\u003c/th\u003e\n\t\t\t\u003cth width=\"100%\"\u003eDescription\u003c/th\u003e\n\t\t\u003c/tr\u003e\n\t\u003cthead\u003e\n\t\u003ctbody\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003esensorPin\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003eThe pin your PIR-sensor is connected to.\u003cbr\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003ePossible values:\u003c/b\u003e \u003ccode\u003eint\u003c/code\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003eDefault value:\u003c/b\u003e \u003ccode\u003e22\u003c/code\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003eNote:\u003c/b\u003e Please use BCM-numbering.\n\t\t\t\u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003esensorState\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003eInvert the GPIO-state that triggers user presence. For example, a \u003ccode\u003e0\u003c/code\u003e value would tell the mirror to trigger user presence when the GPIO pin receives \u003ccode\u003e0\u003c/code\u003e value.\u003cbr\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003ePossible values:\u003c/b\u003e \u003ccode\u003eint (0 or 1)\u003c/code\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003eDefault value:\u003c/b\u003e \u003ccode\u003e1\u003c/code\u003e\n\t\t\t\u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003epowerSaving\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003eShould the monitor be turned off if no user is present? (via HDMI or relay)\u003cbr\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003ePossible values:\u003c/b\u003e \u003ccode\u003eboolean\u003c/code\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003eDefault value:\u003c/b\u003e \u003ccode\u003etrue\u003c/code\u003e\n\t\t\t\u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003epowerSavingDelay\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003eAdditional software side delay (in seconds) before the monitor will be turned off.\u003cbr\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003ePossible values:\u003c/b\u003e \u003ccode\u003eint\u003c/code\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003eDefault value:\u003c/b\u003e \u003ccode\u003e0\u003c/code\u003e\n\t\t\t\u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003erelayPin\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003eIf you want to use a relay to turn of the mirror provide the pin here. If no pin is provided HDMI is turned off instead.\u003cbr\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003ePossible values:\u003c/b\u003e \u003ccode\u003eint\u003c/code\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003eDefault value:\u003c/b\u003e \u003ccode\u003efalse\u003c/code\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003eNote:\u003c/b\u003e Please use BCM-numbering.\n\t\t\t\u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003erelayState\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003eGPIO-state your relay is turned on.\u003cbr\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003ePossible values:\u003c/b\u003e \u003ccode\u003eint (0 or 1)\u003c/code\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003eDefault value:\u003c/b\u003e \u003ccode\u003e1\u003c/code\u003e\n\t\t\t\u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003ealwaysOnPin\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003eIf you would like to use a GPIO pin to trigger power-saving mode. Ideal for users who want to have a physical switch that controls whether or not to use the motion sensor.\u003cbr\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003ePossible values:\u003c/b\u003e \u003ccode\u003eint\u003c/code\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003eDefault value:\u003c/b\u003e \u003ccode\u003efalse\u003c/code\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003eNote:\u003c/b\u003e Please use BCM-numbering.\n\t\t\t\u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003ealwaysOnState\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003eGPIO-state to trigger always-on.\u003cbr\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003ePossible values:\u003c/b\u003e \u003ccode\u003eint (0 or 1)\u003c/code\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003eDefault value:\u003c/b\u003e \u003ccode\u003e1\u003c/code\u003e\n\t\t\t\u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003ealwaysOffPin\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003eIf you would like to use a GPIO pin to trigger sleep mode. Ideal for users who want to have a physical switch to shut off the screen (perhaps the mirror is too bright at night).\u003cbr\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003ePossible values:\u003c/b\u003e \u003ccode\u003eint\u003c/code\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003eDefault value:\u003c/b\u003e \u003ccode\u003efalse\u003c/code\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003eNote:\u003c/b\u003e Please use BCM-numbering.\n\t\t\t\u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003ealwaysOffState\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003eGPIO-state to trigger always-off.\u003cbr\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003ePossible values:\u003c/b\u003e \u003ccode\u003eint (0 or 1)\u003c/code\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003eDefault value:\u003c/b\u003e \u003ccode\u003e1\u003c/code\u003e\n\t\t\t\u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003epowerSavingNotification\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003eTo display a notification before to switch screen off\u003cbr\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003ePossible values:\u003c/b\u003e \u003ccode\u003eboolean\u003c/code\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003eDefault value:\u003c/b\u003e \u003ccode\u003efalse\u003c/code\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003eNote:\u003c/b\u003e Need the default module \"alert\" to be declared on config.js file.\n\t\t\t\u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003epowerSavingMessage\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003eMessage notification to display before to switch screen off\u003cbr\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003eDefault value:\u003c/b\u003e \u003ccode\u003e\"Monitor will be turn Off by PIR module\"\u003c/code\u003e\n\t\t\t\u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003epreventHDMITimeout\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003eWhen \u003ccode\u003epowerSaving\u003c/code\u003e is On: time, in minutes, after which- while HDMI is off- the screen will be briefly turned on and off again, periodically. This is to avoid older HDMI screens from automatically turning Off due to \"No Signal\".\n\t\t\t\t\u003cbr\u003e\u003cb\u003ePossible values:\u003c/b\u003e \u003ccode\u003e0-10\u003c/code\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003eDefault value:\u003c/b\u003e \u003ccode\u003e0\u003c/code\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003eNote:\u003c/b\u003e0 value means that this feature is turned off.\n\t\t\t\u003c/td\u003e\n\t\t\u003c/tr\u003e    \n                \u003ctr\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003esupportCEC\u003c/code\u003e\u003c/td\u003e\n\t\t        \u003ctd\u003eWhen \u003ccode\u003epowerSaving\u003c/code\u003e is On: support CEC to turn monitor ON or OFF as well, not just the HDMI circuit in the RPI.\n\t\t\t\t\u003cbr\u003e\u003cb\u003ePossible values:\u003c/b\u003e \u003ccode\u003eboolean\u003c/code\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003eDefault value:\u003c/b\u003e \u003ccode\u003efalse\u003c/code\u003e\n\t\t\t\u003c/td\u003e\n\t\t\u003c/tr\u003e    \n    \u003ctr\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003epresenceIndicator\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003eWhen module \u003ccode\u003eposition\u003c/code\u003e is defined, thus it is \u003cb\u003evisible\u003c/b\u003e, display an indicator when \u003ccode\u003eUSER_PRESENCE\u003c/code\u003e is detected.\n\t\t\t\t\u003cbr\u003e\u003cb\u003ePossible values:\u003c/b\u003e \u003ccode\u003eFont Awesome icons\u003c/code\u003e [See here](https://fontawesome.com/icons?d=gallery)\n\t\t\t\t\u003cbr\u003e\u003cb\u003eDefault value:\u003c/b\u003e \u003ccode\u003efa-bullseye\u003c/code\u003e\t\t\t\n\t\t\t\t\u003cbr\u003e\u003cb\u003eNote: \u003c/b\u003e Not displayed if set to \u003ccode\u003enull\u003c/code\u003e\n\t\t\t\u003c/td\u003e\n\t\t\u003c/tr\u003e    \n                \u003ctr\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003epresenceIndicatorColor\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003eThe color of \u003ccode\u003epresenceIndicator\u003c/code\u003e, if defined.\n\t\t\t\t\u003cbr\u003e\u003cb\u003ePossible values:\u003c/b\u003e \u003ccode\u003ecolor value\u003c/code\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003eDefault value:\u003c/b\u003e \u003ccode\u003ered\u003c/code\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003eNote: \u003c/b\u003e \u003ccode\u003epresenceIndicator\u003c/code\u003e is not displayed if this parameter is set to \u003ccode\u003enull\u003c/code\u003e\n\t\t\t\u003c/td\u003e\n\t\t\u003c/tr\u003e    \n                \u003ctr\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003epresenceOffIndicator\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003eWhen module \u003ccode\u003eposition\u003c/code\u003e is defined, thus it is \u003cb\u003evisible\u003c/b\u003e, display an indicator when \u003ccode\u003eUSER_PRESENCE\u003c/code\u003e is \u003cb\u003enot\u003c/b\u003e detected.\n\t\t\t\t\u003cbr\u003e\u003cb\u003ePossible values:\u003c/b\u003e \u003ccode\u003eFont Awesome icons\u003c/code\u003e [See here](https://fontawesome.com/icons?d=gallery)\n\t\t\t\t\u003cbr\u003e\u003cb\u003eDefault value:\u003c/b\u003e \u003ccode\u003enull\u003c/code\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003eNote: \u003c/b\u003e Not displayed if set to \u003ccode\u003enull\u003c/code\u003e\n\t\t\t\u003c/td\u003e\n\t\t\u003c/tr\u003e    \n                \u003ctr\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003epresenceOffIndicatorColor\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003eThe color of \u003ccode\u003epresenceOffIndicator\u003c/code\u003e, if defined.\n\t\t\t\t\u003cbr\u003e\u003cb\u003ePossible values:\u003c/b\u003e \u003ccode\u003ecolor value\u003c/code\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003eDefault value:\u003c/b\u003e \u003ccode\u003edimgray\u003c/code\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003eNote: \u003c/b\u003e \u003ccode\u003epresenceOffIndicator\u003c/code\u003e is not displayed if this parameter is set to \u003ccode\u003enull\u003c/code\u003e\n\t\t\t\u003c/td\u003e\n\t\t\u003c/tr\u003e    \n\t\t\u003ctr\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003erunSimulator\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003eTurn on a simulator that will send \u003ccode\u003eUSER_PRESENCE ON\u003c/code\u003e every 20 seconds, and \u003ccode\u003eUSER_PRESENCE OFF\u003c/code\u003e one second after that. \n\t\t\t\t\u003cbr\u003eThis is handy when you want to work on the configuration of the mirror without having to stand up in front of it in order to test.\n\t\t\t\t\u003cbr\u003e\u003cb\u003ePossible values:\u003c/b\u003e \u003ccode\u003eboolean\u003c/code\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003eDefault value:\u003c/b\u003e \u003ccode\u003efalse\u003c/code\u003e\n\t\t\t\t\u003cbr\u003e\u003cb\u003eNote: \u003c/b\u003e Don't forget to turn this one off when using the actual IR sensor!\n\t\t\t\u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\u003c/tbody\u003e\n\u003c/table\u003e\n\n## Example\n\nTo use this module, add it to the modules array in the `config/config.js` file:\n````javascript\nmodules: [\n\t{\n\t\tmodule: 'MMM-PIR-Sensor', \n\t\tposition: \"top_center\", // Remove this line to avoid having an visible indicator\n\t\tconfig: {\n\t\t\tsensorPin: 23,\n\t\t\tpowerSavingDelay: 60, // Turn HDMI OFF after 60 seconds of no motion, until motion is detected again\n\t\t\tpreventHDMITimeout: 4, // Turn HDMI ON and OFF again every 4 minutes when power saving, to avoid LCD/TV timeout\n\t\t\tsupportCEC: true, \n\t\t\tpresenceIndicator: \"fa-eye\", // Customizing the indicator\n\t\t\tpresenceOffIndicator: \"fa-eye\", // Customizing the indicator\n\t\t\tpresenceIndicatorColor: \"#f51d16\", // Customizing the indicator\n\t\t\tpresenceOffIndicatorColor: \"#2b271c\" // Customizing the indicator\n\t\t}\n\t}\n]\n````\n\n## Developer Notes\nThis module broadcasts a `USER_PRESENCE` notification with the payload beeing `true` or `false` you can use it to pause or disable your module.\n\n## Dependencies\n- [wiring-pi](https://www.npmjs.com/package/wiring-pi) (installed via `npm install`)\n\nThe MIT License (MIT)\n=====================\n\nCopyright © 2016 Paul-Vincent Roll\n\nPermission is hereby granted, free of charge, to any person\nobtaining a copy of this software and associated documentation\nfiles (the “Software”), to deal in the Software without\nrestriction, including without limitation the rights to use,\ncopy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following\nconditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\n**The software is provided “as is”, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaviro%2FMMM-PIR-Sensor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaviro%2FMMM-PIR-Sensor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaviro%2FMMM-PIR-Sensor/lists"}