-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuntitled
More file actions
76 lines (64 loc) · 1.62 KB
/
Copy pathuntitled
File metadata and controls
76 lines (64 loc) · 1.62 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
var mongojs = require("mongojs"),
Deferred = require("JQDeferred"),
mongoose = require("mongoose"),
g = require("./global");
var ObjectId = mongoose.Schema.Types.ObjectId;
/*
devices (name, type)
x10
thermostat
"timer"
"state"
events (name, type)
triggers
time-based (incl sunrise, sunset)
device-based (x10 status, change)
actions
event (run)
script
device (trigger, start timer, x10 on/off/dim)
meta
sound, speech
*/
var deviceSchema = new mongoose.Schema({
name: String,
location: String,
group: String,
typeName: String, // x10, timer, variable
driver: String,
id: String,
value: String
});
var triggerSchema = new mongoose.Schema({
typeName: String, // device (variable, timer)
id: String,
value: String
});
var actionSchema = new mongoose.Schema({
typeName: String, // device, event, script, sound, speech
id: String, // subject: A10, timer1, "lights off", "file.wav", "Hello World"
value: String //verb: on/off/dim, start, execute, loadrun, play, speak
});
var eventSchema = new mongoose.Schema({
name: String,
typeName: String,
trigger: triggerSchema,
actions: [ actionSchema ]
});
var accountDeviceSchema = new mongoose.Schema({
macid: String,
accountid: mongoose.Schema.Types.ObjectId,
account: String,
devname: String,
devdescr: String
});
/* accountSchema.methods.setFields = function(name, first, last, level, cb) {
if (name) this.account = name;
if (first) this.firstname = first;
if (last) this.lastname = last;
if (level) this.level = level;
this.save(function(err, obj) {
if (cb) cb(err,obj);
});
}
*/