-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdash.js
More file actions
47 lines (39 loc) · 1017 Bytes
/
Copy pathdash.js
File metadata and controls
47 lines (39 loc) · 1017 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
47
const dash_button = require('node-dash-button');
const Slack = require('./slack.js');
function Dash(auth){
this.slack = new Slack(auth);
}
Dash.prototype.init = function(){
var entryDetected = false;
var exitDetected = false;
//入室用DashButton
const entryButtonAddr = "68:37:e9:7b:a0:b6";
const entryButton = dash_button(entryButtonAddr, null, null, 'all');
//退室用DashBUtton
const exitButtonAddr = "68:37:e9:c5:d4:af";
const exitButton = dash_button(exitButtonAddr, null, null, 'all');
entryButton.on('detected', () => {
if(!entryDetected){
entryDetected = true;
console.log("entry pushed");
this.slack.post(true);
this.now = new Date();
}
setTimeout(() => {
entryDetected = false;
}, 5000);
});
exitButton.on('detected', () => {
if(!exitDetected){
exitDetected = true;
console.log("exit pushed");
this.slack.post(false);
}
setTimeout(() => {
exitDetected = false;
}, 5000);
});
}
function buttonDetected(){
}
module.exports = Dash;