UNPKG

homebridge-philips-hue-sync-box

Version:
61 lines 2.16 kB
import { BaseTvDevice } from './baseTv.js'; export class ModeTvDevice extends BaseTvDevice { platform; accessory; state; mainAccessory; constructor(platform, accessory, state, mainAccessory) { super(platform, accessory, state, mainAccessory); this.platform = platform; this.accessory = accessory; this.state = state; this.mainAccessory = mainAccessory; this.service .getCharacteristic(this.platform.api.hap.Characteristic.ActiveIdentifier) .onSet((value) => { const mode = this.numberToMode.get(value); this.platform.log.debug('Switch mode to ' + mode); this.updateExecution({ mode, }); }); } createInputServices() { const modeInputServices = []; for (const [num, name] of this.numberToMode.entries()) { const position = 'MODE ' + num; const modeInputService = this.getInputService(name, position); // Adds the input as a linked service, which is important so that the input is properly displayed in the Home app this.service.addLinkedService(modeInputService); modeInputServices.push(modeInputService); } this.updateSources(modeInputServices); } getSuffix() { return '-M'; } getServiceSubType() { return 'ModeAccessory'; } getServiceName() { return 'Mode'; } getConfiguredNamePropertyName() { return 'modeTvAccessoryConfiguredName'; } isLightbulbEnabled() { return this.platform.config.modeTvAccessoryLightbulb; } updateTv() { // Updates the mode characteristic const mode = this.state.execution.mode; this.platform.log.debug('Updated mode to ' + mode); const number = this.modeToNumber.get(mode); if (!number) { this.platform.log.error('Unknown mode for Mode TV: ' + mode); return; } this.service.updateCharacteristic(this.platform.api.hap.Characteristic.ActiveIdentifier, number); } } //# sourceMappingURL=modeTv.js.map