forked from christian-fei/homebridge-image-to-camera
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
28 lines (24 loc) · 1.02 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
const CameraAccessory = require('./CameraAccessory')
module.exports = function (homebridge) {
homebridge.registerPlatform('homebridge-image-to-camera', 'image-camera', Platform, true)
function Platform (log, config, api) {
this.CameraAccessory = CameraAccessory(homebridge.hap, homebridge.platformAccessory, log)
this.config = config || {}
this.api = api
this.log = log
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.images) {
return this.log('no images configured', JSON.stringify(this.config))
}
const configuredAccessories = this.config.images.map(conf => new this.CameraAccessory(conf))
this.log('configuredAccessories', configuredAccessories.length)
this.api.publishCameraAccessories('image-camera', configuredAccessories)
}
}