Skip to content

Commit

Permalink
implementing inontime
Browse files Browse the repository at this point in the history
  • Loading branch information
nischi committed Jul 8, 2019
1 parent aba5d20 commit ca0b678
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
37 changes: 30 additions & 7 deletions MMM-MotionControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
* MIT Licensed.
*/

require('moment');

Module.register("MMM-MotionControl",{
defaults: {
delay: 15000,
interval: 5000,
useFacialRecognitionOCV3: false,
useMMMFaceRecoDNN: false
useMMMFaceRecoDNN: false,
ontime: []
},

timeout: null,
Expand All @@ -23,14 +26,34 @@ Module.register("MMM-MotionControl",{
self.sendNotification("GET_LOGGED_IN_USERS");
}, this.config.interval);
}
},
},

inOnTime: function() {
var inOnTime = false;
var today = moment().startOf('day');
this.config.ontime.forEach(time => {
var split = time.split('-');
var from = today.add(split[0].substr(0, 2), 'h').add(split[0].substr(2, 2), 'm');
var to = today.add(split[1].substr(0, 2), 'h').add(split[1].substr(2, 2), 'm');

if (moment().isBetween(from, to)) {
inOnTime = true;
}
});

return inOnTime;
},

notificationReceived: function(notification, payload, sender) {
if (this.config.useFacialRecognitionOCV3 === true) {
this.handleFacialRecognitionOCV3(notification, payload, sender);
}
if (this.config.useMMMFaceRecoDNN === true) {
this.handleFaceRecoDNN(notification, payload, sender);
if (this.inOnTime()) {
_self.sendNotification('CECControl', 'on');
} else {
if (this.config.useFacialRecognitionOCV3 === true) {
this.handleFacialRecognitionOCV3(notification, payload, sender);
}
if (this.config.useMMMFaceRecoDNN === true) {
this.handleFaceRecoDNN(notification, payload, sender);
}
}
},

Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Config | Description
`interval` | Interval to check modules. <br />**Default Value:** `5000`
`useFacialRecognitionOCV3`| Use the module MMM-Facial-Recognition-OCV3 to control the TV<br />**Default Value:** `false`
`useMMMFaceRecoDNN`| Use the module MMM-Face-Reco-DNN to control the TV<br />**Default Value:** `false`
`ontime`| Time where TV is always on. Array with times `['0700-1200', '1300-2000']`.<br />**Default Value:** `[]`

### Full configuration of the module

Expand All @@ -32,7 +33,9 @@ Config | Description
// Use the module MMM-Facial-Recognition-OCV3
useFacialRecognitionOCV3: false,
// Use the module MMM-Face-Reco-DNN
useMMMFaceRecoDNN: false
useMMMFaceRecoDNN: false,
// Array where tv should be on
ontime: []
}
}
```
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "mmm-motioncontrol",
"version": "1.0.0",
"description": "Magic Mirror Module to check motion and turn tv on or off",
"main": "MMM-MotionControl.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/nischi/MMM-MotionControl.git"
},
"keywords": [
"motion",
"control",
"magicmirror",
"module"
],
"author": "Thierry Nischelwitzer",
"license": "MIT",
"bugs": {
"url": "https://github.com/nischi/MMM-MotionControl/issues"
},
"homepage": "https://github.com/nischi/MMM-MotionControl#readme",
"dependencies": {
"moment": "^2.24.0"
}
}

0 comments on commit ca0b678

Please sign in to comment.