homebridge-ir-amplifier
Version: 
Homebridge plugin for IR amplifier control with OCR volume detection and CEC support for Apple TV integration
60 lines • 3.14 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.IRAmplifierPlatform = void 0;
const settings_1 = require("./settings");
const platformAccessory_1 = require("./platformAccessory");
const broadlinkController_1 = require("./broadlinkController");
const tplinkController_1 = require("./tplinkController");
const ocrController_1 = require("./ocrController");
// import { CECController } from './cecController'; // Désactivé - utilise le service CEC externe
class IRAmplifierPlatform {
    // private cecController: CECController; // Désactivé - utilise le service CEC externe
    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.accessories = [];
        this.log.debug('Finished initializing platform:', this.config.name);
        // Initialize controllers
        this.broadlinkController = new broadlinkController_1.BroadlinkController(this.log, this.config);
        this.tplinkController = new tplinkController_1.TPLinkController(this.log, this.config);
        this.ocrController = new ocrController_1.OCRController(this.log, this.config);
        // this.cecController = new CECController(this.log, (this.config as any).cec); // Désactivé - utilise le service CEC externe
        this.api.on('didFinishLaunching', () => {
            log.debug('Executed didFinishLaunching callback');
            this.discoverDevices();
        });
    }
    configureAccessory(accessory) {
        this.log.info('Loading accessory from cache:', accessory.displayName);
        this.accessories.push(accessory);
    }
    discoverDevices() {
        // Create the amplifier accessory
        const uuid = this.api.hap.uuid.generate('ir-amplifier');
        const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
        if (existingAccessory) {
            this.log.info('Restoring existing accessory from cache:', existingAccessory.displayName);
            new platformAccessory_1.IRAmplifierAccessory(this, existingAccessory, this.broadlinkController, this.tplinkController, this.ocrController, null);
        }
        else {
            this.log.info('Adding new accessory: IR Amplifier');
            const accessory = new this.api.platformAccessory('IR Amplifier', uuid);
            accessory.context.device = {
                name: 'IR Amplifier',
                model: 'IR Amplifier',
                serialNumber: 'IR-AMP-001',
            };
            new platformAccessory_1.IRAmplifierAccessory(this, accessory, this.broadlinkController, this.tplinkController, this.ocrController, null);
            this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
        }
    }
}
exports.IRAmplifierPlatform = IRAmplifierPlatform;
// Export the initializer function for Homebridge
module.exports = (api) => {
    api.registerPlatform(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, IRAmplifierPlatform);
};
//# sourceMappingURL=index.js.map