{"id":13830606,"url":"https://github.com/rejas/MMM-MotionDetector","last_synced_at":"2025-07-09T12:30:37.605Z","repository":{"id":47873581,"uuid":"91950657","full_name":"rejas/MMM-MotionDetector","owner":"rejas","description":"This is a motion detector module for MagicMirror","archived":false,"fork":false,"pushed_at":"2023-07-19T05:31:36.000Z","size":162,"stargazers_count":52,"open_issues_count":10,"forks_count":11,"subscribers_count":8,"default_branch":"main","last_synced_at":"2024-11-19T07:06:29.003Z","etag":null,"topics":["javascript","magic-mirror-modules","magicmirror","magicmirror2","motion-detection","raspberry-pi"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rejas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2017-05-21T10:56:36.000Z","updated_at":"2024-11-14T09:43:59.000Z","dependencies_parsed_at":"2024-01-15T17:39:16.187Z","dependency_job_id":"4b9ead87-d560-4465-9d1e-971788a19042","html_url":"https://github.com/rejas/MMM-MotionDetector","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rejas%2FMMM-MotionDetector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rejas%2FMMM-MotionDetector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rejas%2FMMM-MotionDetector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rejas%2FMMM-MotionDetector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rejas","download_url":"https://codeload.github.com/rejas/MMM-MotionDetector/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225539458,"owners_count":17485337,"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":["javascript","magic-mirror-modules","magicmirror","magicmirror2","motion-detection","raspberry-pi"],"created_at":"2024-08-04T10:01:02.916Z","updated_at":"2024-11-20T11:31:02.541Z","avatar_url":"https://github.com/rejas.png","language":"JavaScript","funding_links":[],"categories":["Hardware"],"sub_categories":[],"readme":"# MMM-MotionDetector\n\n## Installation\n\nJust clone the module into your MagicMirror modules folder.\n\nAssuming you are in your MagicMirror directory execute these commands:\n\n```\ncd modules\ngit clone https://github.com/rejas/MMM-MotionDetector.git\n```\n\n## Requirements\n\nAccessing your (web)cam requires to have the client run on localhost or a HTTPS host (due to new requirements in Chrome for getUserMedia).\nThe default value in your MagicMirror config.js is already `localhost` so most users shouldn't be affected.\n\nJust in case you still have problems (like [here](https://github.com/rejas/MMM-MotionDetector/issues/6)) check your config\nand see if you can solve it by outcommenting the ip-address under\n\n```JavaScript\nlet config = {\n    \taddress : '0.0.0.0',\n\t...\n```\n\n### Raspberry Pi OS\n\nDue to some changes on chromium and raspiOS (see https://github.com/rejas/MMM-MotionDetector/issues/56) the [legacy raspios](https://www.raspberrypi.com/news/new-old-functionality-with-raspberry-pi-os-legacy/) is needed.\n\nAny help getting this module run on the default raspiOS is greatly appreciated!\n\nSome people had success with enabling the legacy camera mode in the default raspiOS, but this is not a 100% confirmed:\n\n```\nsudo raspi-config\n```\n\nThen go to\n\n```\n3 Interface Options -\u003e I1 Legacy Camera\n```\n\nand enable legacy camera support.\n\n### Tested devices\n\nSo far I only used a [PlayStation3 Eye Webcam](https://en.wikipedia.org/wiki/PlayStation_Eye) for motion-detection at my MagicMirror.\nIf you have successfully used this module with any other webcam, I'd be happy to hear about it.\n\nIf you want to use the wired PI-camera follow these steps provided by [@rev138](https://github.com/rejas/MMM-MotionDetector/issues/8#issuecomment-483356950):\n\n    - Open /etc/modules-load.d/modules.conf\n    - Add bcm2835-v4l2 to the end of the file and save it.\n    - Reboot.\n    - Profit\n\nAnother tutorial on how to enable the PI-camera in the browser can be found [in this blog post](https://reprage.com/post/pi-camera-module-in-the-browser).\n\n### Mac support\n\nThanks to [3vidar](https://github.com/3vidar) you can also use this module on a Mac.\nFor now the code only resides in the branch called \"mac\" in this git repo.\n\nI hope to find the time to generalize it and have it in the mainline too.\n\n## Configuration\n\nTo use this module, add it to the modules array in the `config/config.js` file:\n\n```javascript\nmodules: [\n  {\n    module: \"MMM-MotionDetector\",\n    position: \"top_left\", // Optional. This can be any of the regions. Displays debug informations.\n    config: {\n      // The config property is optional.\n      // See 'Configuration options' for more information.\n    },\n  },\n];\n```\n\n### Configuration options\n\nThe following properties can be configured:\n\n| Option                | Description                                                                                                                                               |\n| --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `captureIntervalTime` | Time in ms between capturing images for detection\u003cbr\u003e\u003cbr\u003e**Default value:** `1000`                                                                        |\n| `scoreThreshold`      | Threshold minimum for an image to be considered significant\u003cbr\u003e\u003cbr\u003e**Default value:** `20`                                                                |\n| `timeout`             | Time in ms after which monitor is turned off when no motion is detected\u003cbr\u003e\u003cbr\u003eSet to -1 to never turn off the monitor\u003cbr\u003e\u003cbr\u003e**Default value:** `120000` |\n| `deviceId`            | (optional) specify which camera to use in case multiple exist in the system.                                                                              |\n\n#### How to get the deviceId\n\nYou need to retrieve the deviceId from the browser / electron instance you are running this module on.\n\n- If you are running it in a browser, use this command in the web console `navigator.mediaDevices.enumerateDevices()` to get all devices.\n- In the standard MM Electron, add 'export ELECTRON_ENABLE_LOGGING=true' to the mm.sh. Then cat the pm2 error logs and look for the DeviceID.\n\n### Configuring MotionDetector with another module that requires MagicMirror address to be 0.0.0.0\n\nYou can do this by doing a simple workaround. You need to config the MagicMirror address to localhost (default)\nand set up a reverse proxy for the other module.\n\nAs MagicMirror uses an express server, you can install http-proxy-middleware plugin for express.\nThen you need to create 2 files:\n\nroutes.json\n\n```JavaScript\n{\n  \"routes\": [\n    {\n      \"route\": \"/mirror\", // any path you like\n      \"address\": \"http://localhost:8080\" // adrress of MagicMirror\n    }\n  ]\n}\n```\n\nproxyserver.js\n\n```JavaScript\n// Dependencies\nconst express = require('express');\nconst proxy = require('http-proxy-middleware');\n\n// Config\nconst { routes } = require('./routes.json');\n\nconst app = express();\n\nfor (route of routes) {\n    app.use(route.route,\n        proxy({\n            target: route.address,\n            pathRewrite: (path, req) =\u003e {\n                return path.split('/').slice(2).join('/'); // Could use replace, but take care of the leading '/'\n            }\n        })\n    );\n}\n\n// Start server and listen on port 8081\napp.listen(8081, () =\u003e {});\n```\n\nNow just start the proxyserver e.g. with PM2 like you may run your MagicMirror.\n\nYou can now call http://ipaddress:8081/mirror/modulename and it will be forwarded to http://localhost:8080/modulename.\n\nAs you are bypassing browser security with this workaround you may want to add some credentials and/or ip-ranges which can access your proxyserver.\n\n## Notifications send\n\n| Notification         | Payload       | Description                                                             |\n| -------------------- | ------------- | ----------------------------------------------------------------------- |\n| `MOTION_DETECTED`    | score         | score calculated by the diff-cam-engine, 0 or greater                   |\n| `DEACTIVATE_MONITOR` | percentageOff | percentage of time the monitor was deactivated since the module started |\n\n## Changelog\n\n### [1.6.0] - 2020-07-05\n\n- Allow disabling the monitor-functionality and just get the motion detection\n- Use Logger from MM² core\n- Update dependencies\n\n### [1.5.0] - 2019-07-14\n\n- Show error on UI element when something goes wrong during initialization\n- Cleaned up code\n- Update dependencies\n\n### [1.4.0] - 2019-03-08\n\n- Updated code to getUserMedia from browser\n- Cleaned up DOM template\n\n### [1.3.0] - 2019-03-06\n\n- Added time/percentage powered-off to DOM\n- Switched to DOM templating\n\n### [1.2.2] - 2019-03-06\n\n- Switched to MM² codestyle\n- Cleaned up code\n\n### [1.2.1] - 2019-03-02\n\n- Added eslint codestyles\n\n### [1.2.0] - 2019-03-01\n\n- Added DOM for displaying basic debug information on the MagicMirror when a position is specified\n- Updated documentation\n\n### [1.1.0] - 2018-11-01\n\n- Switched from tvservice to vgcencmd. Module can now be used with vc4-kms-v3d and vc4-fkms-v3d drivers.\n\n### [1.0.0] - 2018-07-20\n\n- Initial release\n\n## Acknowledgements\n\nMany thanks to\n\n- [alexyak](https://github.com/alexyak/motiondetector) for the original module code\n- [lonekorean](https://github.com/lonekorean/diff-cam-engine/) for the diffcam engine code.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frejas%2FMMM-MotionDetector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frejas%2FMMM-MotionDetector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frejas%2FMMM-MotionDetector/lists"}