-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscriptlib.js
More file actions
56 lines (41 loc) · 1.14 KB
/
Copy pathscriptlib.js
File metadata and controls
56 lines (41 loc) · 1.14 KB
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
var evactions = require("./evactions"),
g = require("./globals");
function scriptlib() {
var self = this;
// for scripts
this.variable = function(id) {
return g.variableDriver.get(id);
}
this.variableSet = function(id, val) {
return self.deviceAction(id,val);
}
this.variableSetParm = function(id, val, parm) {
return self.deviceAction(id,val,parm);
}
this.deviceAction = function(id, val, parameter) {
var act = {do: 'device', name: id, value: val };
if (parameter) {
act['parm'] = parameter;
}
return g.executeAction(act, true);
}
this.scriptrun = function(name,val,parm) {
return g.executeAction({do: "script", name: name, value: val, parm: parm},true);
}
this.log = function(s) {
return g.log(g.LOG_TRACE,s);
}
this.deviceState = function(id) {
return g.devicemap[id].state;
}
this.deviceLatest = function(id) {
return g.devicemap[id].latest;
}
this.say = function(s) {
return g.executeAction({do: 'speak', value: s},null);
}
this.curl = function(method, url, parms) {
return g.curl(method,url,parms);
}
}
module.exports = new scriptlib();