homebridge-saphi-tv
Version:
This plugin allows you to control your SaphiOS PhilipsTV with support for Apps, Sources and Channels as well as Ambilight, Ambilight+Hue and a CC Remote.
55 lines • 2.66 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SaphiTvPlatform = void 0;
const settings_1 = require("./settings");
const tvAccessory_1 = require("./tvAccessory");
const configuration_1 = require("./configuration");
const utilities_1 = require("./utilities");
/**
* HomebridgePlatform
* This class is the main constructor for your plugin, this is where you should
* parse the user config and discover/register accessories with Homebridge.
*/
class SaphiTvPlatform {
constructor(log, config, api) {
this.log = log;
this.config = config;
this.api = api;
this.Service = this.api.hap.Service;
this.Characteristic = this.api.hap.Characteristic;
// this is used to track restored cached accessories
this.accessories = [];
this.log.info('Finished initializing platform: ' + settings_1.PLATFORM_NAME);
api.on("didFinishLaunching" /* DID_FINISH_LAUNCHING */, () => {
this.log.info('Finished launching platform:', settings_1.PLATFORM_NAME);
this.publishExampleExternalAccessory();
});
}
configureAccessory(accessory) {
this.log.info('Loading accessory from cache:', accessory.displayName);
accessory.on("identify" /* IDENTIFY */, () => {
this.log.info('%s identified', accessory.displayName);
});
this.accessories.push(accessory);
}
removeAllAccessories() {
this.log.info('removing all accessories');
this.api.unregisterPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, this.accessories);
this.accessories.splice(0, this.accessories.length);
}
publishExampleExternalAccessory() {
this.removeAllAccessories();
const tvName = this.config.name || 'Saphi TV';
const uuidTv = this.api.hap.uuid.generate(settings_1.PLUGIN_NAME + tvName);
const tvAccessory = new this.api.platformAccessory(tvName, uuidTv);
const uuidRemote = this.api.hap.uuid.generate(settings_1.PLUGIN_NAME + tvName + ' Remote');
const remoteAccessory = new this.api.platformAccessory(tvName + ' Remote', uuidRemote);
const configuration = new configuration_1.Configuration(this.config);
const utilities = new utilities_1.Utilities(configuration, this);
new tvAccessory_1.TelevisionAccessory(utilities, tvAccessory, remoteAccessory);
this.log.info('Publishing TV & Remote');
this.api.publishExternalAccessories(settings_1.PLUGIN_NAME, [tvAccessory, remoteAccessory]);
}
}
exports.SaphiTvPlatform = SaphiTvPlatform;
//# sourceMappingURL=platform.js.map