Skip to content

Commit 7cb2586

Browse files
authored
1.7.0
2 parents 689ea05 + 1563988 commit 7cb2586

21 files changed

+6986
-1223
lines changed

.github/dependabot.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
schedule:
6+
interval: monthly
7+
8+
- package-ecosystem: npm
9+
directory: /
10+
schedule:
11+
interval: monthly
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Automated Tests
2+
on:
3+
push:
4+
branches: [main, develop]
5+
pull_request:
6+
branches: [main, develop]
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
run-lint:
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 30
15+
steps:
16+
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
17+
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
18+
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
19+
- name: Check out repository code
20+
uses: actions/checkout@v5
21+
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
22+
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
23+
- name: Use Node.js
24+
uses: actions/setup-node@v5
25+
with:
26+
node-version: lts/*
27+
cache: npm
28+
- name: Install dependencies
29+
run: npm ci
30+
- name: Check spelling
31+
run: node --run test:spelling
32+
- name: Check linting
33+
run: node --run lint
34+
- name: Report status
35+
if: always()
36+
run: echo "🍏 This job's status is ${{ job.status }}."

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx lint-staged

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.js
2+
*.mjs

.prettierrc.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
## [develop](https://github.com/rejas/MMM-MotionDetector/compare/v1.7.0...develop) - unreleased
8+
9+
## [1.7.0](https://github.com/rejas/MMM-MotionDetector/compare/v1.6.0...v1.7.0) - 2025-11-15
10+
11+
- Update linting (#61)
12+
- Update logging (#62)
13+
- Added github actions for testing (#63)
14+
- Added platform config option incl mac (#64, #65)
15+
- Use async calls everywhere in module (#66)
16+
- Update dependencies
17+
18+
## [1.6.0](https://github.com/rejas/MMM-MotionDetector/compare/v1.5.0...v1.6.0) - 2020-07-05
19+
20+
- Allow disabling the monitor-functionality and just get the motion detection
21+
- Use Logger from MM² core
22+
- Update dependencies
23+
24+
## [1.5.0](https://github.com/rejas/MMM-MotionDetector/compare/v1.4.0...v1.5.0) - 2019-07-14
25+
26+
- Show error on UI element when something goes wrong during initialization
27+
- Cleaned up code
28+
- Update dependencies
29+
30+
## [1.4.0](https://github.com/rejas/MMM-MotionDetector/compare/v1.3.0...v1.4.0) - 2019-03-08
31+
32+
- Updated code to getUserMedia from browser
33+
- Cleaned up DOM template
34+
35+
## [1.3.0](https://github.com/rejas/MMM-MotionDetector/compare/v1.2.2...v1.3.0) - 2019-03-06
36+
37+
- Added time/percentage powered-off to DOM
38+
- Switched to DOM templating
39+
40+
## [1.2.2](https://github.com/rejas/MMM-MotionDetector/compare/v1.2.1...v1.2.2) - 2019-03-06
41+
42+
- Switched to MM² codestyle
43+
- Cleaned up code
44+
45+
## [1.2.1](https://github.com/rejas/MMM-MotionDetector/compare/v1.2.0...v1.2.1) - 2019-03-02
46+
47+
- Added eslint code styles
48+
49+
## [1.2.0](https://github.com/rejas/MMM-MotionDetector/compare/v1.1.0...v1.2.0) - 2019-03-01
50+
51+
- Added DOM for displaying basic debug information on the MagicMirror when a position is specified
52+
- Updated documentation
53+
54+
## [1.1.0](https://github.com/rejas/MMM-MotionDetector/compare/v1.0.0...v1.1.0) - 2018-11-01
55+
56+
- Switched from tvservice to vcgencmd. Module can now be used with vc4-kms-v3d and vc4-fkms-v3d drivers.
57+
58+
## [1.0.0](https://github.com/rejas/MMM-MotionDetector/releases/tag/v1.0.0) - 2018-07-20
59+
60+
- Initial release

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2021 rejas
3+
Copyright (c) 2025 rejas
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

MMM-MotionDetector.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
/* global DiffCamEngine */
1+
/* global DiffCamEngine, Log, Module, moment */
22
Module.register("MMM-MotionDetector", {
33
defaults: {
44
captureIntervalTime: 1000, // 1 second
5+
platform: "x11",
56
scoreThreshold: 20,
67
timeout: 120000, // 2 minutes,
78
deviceId: null,
@@ -47,16 +48,15 @@ Module.register("MMM-MotionDetector", {
4748
},
4849

4950
start: function () {
50-
Log.info("MMM-MotionDetector: starting up");
51+
Log.info("starting up for platform " + this.config.platform + ".");
5152

5253
this.data.header = "MMM-MotionDetector";
5354
this.lastScoreDetected = 0;
5455
this.lastTimeMotionDetected = new Date();
5556
this.lastTimePoweredOff = new Date();
5657
this.timeStarted = new Date().getTime();
5758

58-
// make sure that the monitor is on when starting
59-
this.sendSocketNotification("ACTIVATE_MONITOR");
59+
this.sendSocketNotification("INIT_MONITOR", this.config.platform);
6060

6161
const canvas = document.createElement("canvas");
6262
const video = document.createElement("video");
@@ -72,11 +72,11 @@ Module.register("MMM-MotionDetector", {
7272
motionCanvas: canvas,
7373
scoreThreshold: this.config.scoreThreshold,
7474
initSuccessCallback: () => {
75-
Log.info("MMM-MotionDetector: DiffCamEngine init successful.");
75+
Log.info("DiffCamEngine init successful.");
7676
DiffCamEngine.start();
7777
},
7878
initErrorCallback: (error) => {
79-
Log.error("MMM-MotionDetector: DiffCamEngine init failed: " + error);
79+
Log.error(`DiffCamEngine init failed: ${error}`);
8080
this.error = error;
8181
this.updateDom();
8282
},
@@ -86,10 +86,11 @@ Module.register("MMM-MotionDetector", {
8686
2
8787
);
8888
if (hasMotion) {
89-
Log.info("MMM-MotionDetector: Motion detected, score " + score);
89+
Log.info(`Motion detected, score: ${score}`);
9090
this.sendSocketNotification("MOTION_DETECTED", { score: score });
9191
this.sendNotification("MOTION_DETECTED", { score: score });
9292
if (this.poweredOff) {
93+
Log.info(`Percentage of uptime powered off: ${this.percentagePoweredOff}`);
9394
this.sendSocketNotification("ACTIVATE_MONITOR");
9495
this.poweredOffTime = this.poweredOffTime + (currentDate.getTime() - this.lastTimePoweredOff.getTime());
9596
this.poweredOff = false;

README.md

Lines changed: 17 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Just clone the module into your MagicMirror modules folder.
66

77
Assuming you are in your MagicMirror directory execute these commands:
88

9-
```
9+
```shell
1010
cd modules
1111
git clone https://github.com/rejas/MMM-MotionDetector.git
1212
```
@@ -17,7 +17,7 @@ Accessing your (web)cam requires to have the client run on localhost or a HTTPS
1717
The default value in your MagicMirror config.js is already `localhost` so most users shouldn't be affected.
1818

1919
Just in case you still have problems (like [here](https://github.com/rejas/MMM-MotionDetector/issues/6)) check your config
20-
and see if you can solve it by outcommenting the ip-address under
20+
and see if you can solve it by uncommenting the ip-address under
2121

2222
```JavaScript
2323
let config = {
@@ -27,19 +27,19 @@ let config = {
2727
2828
### Raspberry Pi OS
2929
30-
Due 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.
30+
Due 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.
3131
3232
Any help getting this module run on the default raspiOS is greatly appreciated!
3333
3434
Some people had success with enabling the legacy camera mode in the default raspiOS, but this is not a 100% confirmed:
3535
36-
```
36+
```shell
3737
sudo raspi-config
3838
```
3939
4040
Then go to
4141
42-
```
42+
```shell
4343
3 Interface Options -> I1 Legacy Camera
4444
```
4545
@@ -59,13 +59,6 @@ If you want to use the wired PI-camera follow these steps provided by [@rev138](
5959
6060
Another 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).
6161
62-
### Mac support
63-
64-
Thanks to [3vidar](https://github.com/3vidar) you can also use this module on a Mac.
65-
For now the code only resides in the branch called "mac" in this git repo.
66-
67-
I hope to find the time to generalize it and have it in the mainline too.
68-
6962
## Configuration
7063
7164
To use this module, add it to the modules array in the `config/config.js` file:
@@ -74,25 +67,26 @@ To use this module, add it to the modules array in the `config/config.js` file:
7467
modules: [
7568
{
7669
module: "MMM-MotionDetector",
77-
position: "top_left", // Optional. This can be any of the regions. Displays debug informations.
70+
position: "top_left", // Optional. This can be any of the regions. Displays debug information.
7871
config: {
7972
// The config property is optional.
8073
// See 'Configuration options' for more information.
81-
},
82-
},
74+
}
75+
}
8376
];
8477
```
8578
8679
### Configuration options
8780
8881
The following properties can be configured:
8982
90-
| Option | Description |
91-
| --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
92-
| `captureIntervalTime` | Time in ms between capturing images for detection<br><br>**Default value:** `1000` |
93-
| `scoreThreshold` | Threshold minimum for an image to be considered significant<br><br>**Default value:** `20` |
94-
| `timeout` | Time in ms after which monitor is turned off when no motion is detected<br><br>Set to -1 to never turn off the monitor<br><br>**Default value:** `120000` |
95-
| `deviceId` | (optional) specify which camera to use in case multiple exist in the system. |
83+
| Option | Description | Default value |
84+
| --------------------- | ---------------------------------------------------------------------------------------------------------------------- | ------------- |
85+
| `captureIntervalTime` | Time in ms between capturing images for detection | `1000` |
86+
| `deviceId` | (optional) specify which camera to use in case multiple exist in the system. | |
87+
| `platform` | On what platforms this runs. <br><br>**Possible values:** `cec` (untested), `labwc`,`mac-intel`, `mac-intel`, `x11` | `x11` |
88+
| `scoreThreshold` | Threshold minimum for an image to be considered significant | `20` |
89+
| `timeout` | Time in ms after which monitor is turned off when no motion is detected<br><br>Set to -1 to never turn off the monitor | `120000` |
9690
9791
#### How to get the deviceId
9892
@@ -116,7 +110,7 @@ routes.json
116110
"routes": [
117111
{
118112
"route": "/mirror", // any path you like
119-
"address": "http://localhost:8080" // adrress of MagicMirror
113+
"address": "http://localhost:8080" // address of MagicMirror
120114
}
121115
]
122116
}
@@ -162,55 +156,9 @@ As you are bypassing browser security with this workaround you may want to add s
162156
| `MOTION_DETECTED` | score | score calculated by the diff-cam-engine, 0 or greater |
163157
| `DEACTIVATE_MONITOR` | percentageOff | percentage of time the monitor was deactivated since the module started |
164158
165-
## Changelog
166-
167-
### [1.6.0] - 2020-07-05
168-
169-
- Allow disabling the monitor-functionality and just get the motion detection
170-
- Use Logger from MM² core
171-
- Update dependencies
172-
173-
### [1.5.0] - 2019-07-14
174-
175-
- Show error on UI element when something goes wrong during initialization
176-
- Cleaned up code
177-
- Update dependencies
178-
179-
### [1.4.0] - 2019-03-08
180-
181-
- Updated code to getUserMedia from browser
182-
- Cleaned up DOM template
183-
184-
### [1.3.0] - 2019-03-06
185-
186-
- Added time/percentage powered-off to DOM
187-
- Switched to DOM templating
188-
189-
### [1.2.2] - 2019-03-06
190-
191-
- Switched to MM² codestyle
192-
- Cleaned up code
193-
194-
### [1.2.1] - 2019-03-02
195-
196-
- Added eslint codestyles
197-
198-
### [1.2.0] - 2019-03-01
199-
200-
- Added DOM for displaying basic debug information on the MagicMirror when a position is specified
201-
- Updated documentation
202-
203-
### [1.1.0] - 2018-11-01
204-
205-
- Switched from tvservice to vgcencmd. Module can now be used with vc4-kms-v3d and vc4-fkms-v3d drivers.
206-
207-
### [1.0.0] - 2018-07-20
208-
209-
- Initial release
210-
211159
## Acknowledgements
212160
213161
Many thanks to
214162
215163
- [alexyak](https://github.com/alexyak/motiondetector) for the original module code
216-
- [lonekorean](https://github.com/lonekorean/diff-cam-engine/) for the diffcam engine code.
164+
- [lonekorean](https://github.com/lonekorean/diff-cam-engine/) for the diff-cam-engine code.

cspell.config.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"version": "0.2",
3+
"language": "en",
4+
"words": [
5+
"alexyak",
6+
"caffeinate",
7+
"displaysleepnow",
8+
"fkms",
9+
"initialising",
10+
"ioreg",
11+
"labwc",
12+
"lonekorean",
13+
"motiondetector",
14+
"pmset",
15+
"proxyserver",
16+
"randr",
17+
"raspi",
18+
"raspiOS",
19+
"rejas",
20+
"tvservice",
21+
"vcgencmd"
22+
],
23+
"ignorePaths": ["node_modules/**"],
24+
"dictionaries": ["node"]
25+
}

0 commit comments

Comments
 (0)