forked from paviro/MMM-PIR-Sensor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMMM-PIR-Sensor.js
49 lines (44 loc) · 1.25 KB
/
MMM-PIR-Sensor.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* global Module */
/* Magic Mirror
* Module: MMM-PIR-Sensor
*
* By Paul-Vincent Roll http://paulvincentroll.com
* MIT Licensed.
*/
Module.register('MMM-PIR-Sensor',{
requiresVersion: '2.1.0',
defaults: {
sensorPin: 534,
sensorState: 1,
relayPin: false,
relayState: 1,
alwaysOnPin: false,
alwaysOnState: 1,
alwaysOffPin: false,
alwaysOffState: 1,
powerSaving: true,
powerSavingDelay: 0,
powerSavingNotification: false,
powerSavingMessage: "Monitor will be turn Off by PIR module",
},
// Override socket notification handler.
socketNotificationReceived: function (notification, payload) {
if (notification === 'USER_PRESENCE') {
this.sendNotification(notification, payload)
if (payload === false && this.config.powerSavingNotification === true){
this.sendNotification("SHOW_ALERT",{type:"notification", message:this.config.powerSavingMessage});
}
} else if (notification === 'SHOW_ALERT') {
this.sendNotification(notification, payload)
}
},
notificationReceived: function (notification, payload) {
if (notification === 'SCREEN_WAKEUP') {
this.sendNotification(notification, payload)
}
},
start: function () {
this.sendSocketNotification('CONFIG', this.config);
Log.info('Starting module: ' + this.name);
}
});