forked from YinHangCode/homebridge-mi-outlet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
63 lines (49 loc) · 1.69 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
require('./Devices/PlugBase');
// require('./Devices/IntelligencePinboard');
// require('./Devices/QingPinboard');
var Accessory, Service, Characteristic, UUIDGen;
module.exports = function(homebridge) {
Accessory = homebridge.platformAccessory;
PlatformAccessory = homebridge.platformAccessory;
Service = homebridge.hap.Service;
Characteristic = homebridge.hap.Characteristic;
UUIDGen = homebridge.hap.uuid;
homebridge.registerPlatform('homebridge-mi-outlet', 'MiOutlet', MiOutlet);
}
function MiOutlet(log, config, api) {
if(null == config) {
return;
}
this.Accessory = Accessory;
this.PlatformAccessory = PlatformAccessory;
this.Service = Service;
this.Characteristic = Characteristic;
this.UUIDGen = UUIDGen;
this.log = log;
this.config = config;
if (api) {
this.api = api;
}
}
MiOutlet.prototype = {
accessories: function(callback) {
var myAccessories = [];
var cfgAccessories = this.config['accessories'];
if(null == cfgAccessories) {
return;
}
for (var i = 0; i < cfgAccessories.length; i++) {
var cfgAccessory = cfgAccessories[i];
if (cfgAccessory['type'] == "PlugBase") {
new PlugBase(this, cfgAccessory).forEach(function(accessory, index, arr){
myAccessories.push(accessory);
});
} else if (cfgAccessory['type'] == "IntelligencePinboard") {
} else if (cfgAccessory['type'] == "Intelligence6Pinboard") {
} else if (cfgAccessory['type'] == "QingPinboard") {
} else {
}
}
callback(myAccessories);
}
}