-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathindex.js
More file actions
30 lines (26 loc) · 1.02 KB
/
Copy pathindex.js
File metadata and controls
30 lines (26 loc) · 1.02 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
"use strict";
var Accessory, hap;
module.exports = function (homebridge) {
Accessory = homebridge.platformAccessory;
hap = homebridge.hap;
homebridge.registerPlatform("homebridge-website-to-camera", "website-camera", Platform, true);
};
function Platform(log, config, api) {
this.CameraAccessory = require("./CameraAccessory")(hap, Accessory, log);
this.config = config || {};
this.api = api;
if (!api || api.version < 2.1) {
throw new Error("Unexpected API version.");
}
api.on("didFinishLaunching", this.didFinishLaunching.bind(this));
}
Platform.prototype.configureAccessory = function (accessory) {
};
Platform.prototype.didFinishLaunching = function () {
if (!this.config.cameras) {
return
}
const configuredAccessories = this.config.cameras.map(conf => new this.CameraAccessory(conf));
const publish = this.api.publishCameraAccessories || this.api.publishExternalAccessories;
publish.call(this.api, "homebridge-website-to-camera", configuredAccessories);
};