-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMMM-Doorbell.js
64 lines (59 loc) · 1.44 KB
/
MMM-Doorbell.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
Module.register("MMM-Doorbell",{
defaults: {
is_img: false,
file_path: "1.png",
text: "DOORBELL IS READY."
},
getDom: function() {
var wrapper = document.createElement("div");
if(this.config.is_img){
var img = document.createElement("img");
img.src = "modules/MMM-Doorbell/"+this.config.file_path;
img.width = "640";
wrapper.appendChild(img);
}
else{
wrapper.innerHTML = this.config.text;
}
return wrapper;
},
start: function() {
this.sendSocketNotification("READY");
},
// getScripts: function() {
// return [
// 'reconnecting-websocket.js',
// ]
// },
// notificationReceived: function(notification, payload, sender) {
// },
show_runing(){
this.config.text = "DOORBELL IS READY.";
this.updateDom(500);
},
socketNotificationReceived: function(notification, payload){
if(notification == "IS_A_FACE"){
var that = this;
//保存照片路径
this.config.file_path = payload;
//更新照片
this.config.is_img = true;
//展示照片
this.updateDom(500);
//展示照片一段时间
setTimeout(function() {
//发送helper展示完成
that.config.is_img = false;
that.sendSocketNotification("SHOWED");
}, 5000);
}
else if(notification == "RUNING"){
this.show_runing();
}
else if(notification == "CLOSE"){
//展示连接断开,模块停止工作
this.config.text = "DISCONNECTED, TRY TO RECONNECT. PLEASE CHECK.";
this.updateDom(500);
}
}
});