UNPKG

homebridge-syntex-webhooks

Version:
45 lines (34 loc) 1.34 kB
const { DynamicPlatform } = require('homebridge-syntex-dynamic-platform'); const SynTexUniversalAccessory = require('./src/universal'); const DeviceManager = require('./src/device-manager'); const pluginID = 'homebridge-syntex-webhooks'; const pluginName = 'SynTexWebHooks'; const pluginVersion = require('./package.json').version; module.exports = (homebridge) => homebridge.registerPlatform(pluginID, pluginName, SynTexWebHookPlatform, true); class SynTexWebHookPlatform extends DynamicPlatform { constructor(log, config, api) { super(config, api, pluginID, pluginName, pluginVersion); if(this.api != null && this.logger != null && this.files != null) { this.api.on('didFinishLaunching', () => { this.DeviceManager = new DeviceManager(this); this.loadAccessories(); }); } else { throw new Error('Minimal parameters not configurated. Please check the README! https://github.com/SynTexDZN/homebridge-syntex-webhooks/blob/master/README.md'); } } loadAccessories() { for(const device of this.devices) { const homebridgeAccessory = this.getAccessory(device.id); device.manufacturer = this.pluginName; this.addAccessory(new SynTexUniversalAccessory(homebridgeAccessory, device, { platform : this, DeviceManager : this.DeviceManager })); } } }