-
Notifications
You must be signed in to change notification settings - Fork 14
/
index.js
executable file
·46 lines (34 loc) · 1.16 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
var Accessory, hap, UUIDGen;
var iSight = require('./iSight').iSight;
module.exports = function(homebridge) {
Accessory = homebridge.platformAccessory;
hap = homebridge.hap;
UUIDGen = homebridge.hap.uuid;
homebridge.registerPlatform("homebridge-camera-isight", "Camera-iSight", iSightPlatform, true);
}
function iSightPlatform(log, config, api) {
var self = this;
self.log = log;
self.config = config;
if (api) {
self.api = api;
if (api.version < 2.1) {
throw new Error("Unexpected API version.");
}
self.api.on('didFinishLaunching', self.didFinishLaunching.bind(this));
}
}
iSightPlatform.prototype.configureAccessory = function(accessory) {
// Won't be invoked
}
iSightPlatform.prototype.didFinishLaunching = function() {
var self = this;
if(self.config) {
var name = "iSight Camera" || self.config.name;
var uuid = UUIDGen.generate(name);
var cameraAccessory = new Accessory(name, uuid, hap.Accessory.Categories.CAMERA);
var cameraSource = new iSight(hap, self.config);
cameraAccessory.configureCameraSource(cameraSource);
self.api.publishCameraAccessories("Camera-iSight", [cameraAccessory]);
}
}