-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
77 lines (63 loc) · 1.53 KB
/
index.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
65
66
67
68
69
70
71
72
73
74
75
76
77
'use strict';
class StarterDriver {
constructor(driverSettingsObj, interfaces) {
var self = this;
this.interface = interfaces[this.getInterface()];
}
getName() {
return 'starter';
}
getType() {
return 'switch';
}
getInterface() {
return 'http';
}
setEventEmitter(eventEmitter) {
this.eventEmitter = eventEmitter;
//when something happens with this device you can emit an event to let the homebox platform know:
//it should only emit events which are valid types (see documentation for more info)
//this.eventEmitter.emit('eventType','driverId','deviceId','value')
//E.g:
//this.eventEmitter.emit('didSomething','starter','defghi','abc123');
}
initDevices(devices) {
}
getAuthenticationProcess() {
return [];
}
discover() {
return new Promise(function(resolve) {
var devices = [];
//find any devices on the network here, then add them to devices array
var device = {
deviceId: 'uniqueSerialNumber',
name: 'nameOfDevice',
address: 'ipAddressOfDevice',
capabilities: { //the list of capabilities listed here should reflect the capabilities of the type of device
on: true,
off: true
}
};
devices.push(device);
resolve(devices);
});
}
capability_on(device, props) {
return new Promise(function(resolve) {
//turn the device on here
resolve({
on: true
});
});
}
capability_off(device, props) {
return new Promise(function(resolve) {
//turn the device off here
resolve({
off: true
});
});
}
}
module.exports = StarterDriver;