forked from paviro/MMM-PIR-Sensor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMMM-PIR-Sensor.js
More file actions
46 lines (39 loc) · 988 Bytes
/
Copy pathMMM-PIR-Sensor.js
File metadata and controls
46 lines (39 loc) · 988 Bytes
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
/* 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: 22,
invertSensorValue: false,
relayPIN: false,
relayOnState: 1,
powerSaving: true,
powerSavingDelay: 0,
},
// Override socket notification handler.
socketNotificationReceived: function(notification, payload) {
if (notification === "USER_PRESENCE"){
this.sendNotification(notification, payload)
}
},
notificationReceived: function(notification, payload) {
if (notification === "SCREEN_WAKEUP"){
this.sendNotification(notification, payload)
}
},
start: function() {
if (this.config.relayOnState == 1){
this.config.relayOffState = 0
}
else if (this.config.relayOnState == 0){
this.config.relayOffState = 1
}
this.sendSocketNotification('CONFIG', this.config);
Log.info('Starting module: ' + this.name);
}
});