UNPKG

homebridge-pioneer-avr-2025

Version:

A Pioneer AVR plugin for homebridge. This plugin is designed for Pioneer models that use Telnet Commands (e.g., VSX-922). It may not be compatible with newer models (e.g., VSX-LX304).

97 lines 4.01 kB
"use strict"; // src/pioneer-avr/pioneerAvr.ts var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const initialize_1 = require("./initialize"); const inputs_1 = require("./inputs"); const power_1 = require("./power"); const volume_1 = require("./volume"); /** * The main PioneerAvr class responsible for handling AVR functionality. * Mixins are applied in a specific order to ensure proper initialization. */ class PioneerAvr extends (0, initialize_1.InitializeMixin)((0, inputs_1.InputManagementMixin)((0, power_1.PowerManagementMixin)((0, volume_1.VolumeManagementMixin)(class { constructor(platform, accessory, pioneerAvrClassCallback) { this.maxVolume = 80; // Default max volume this.minVolume = 20; // Default min volume this.isReady = false; this.lastUserInteraction = Date.now(); this.platform = platform; this.api = platform.api; this.log = platform.log; this.host = accessory.device.host; this.port = accessory.device.port; this.device = accessory.device; this.accessory = accessory; this.service = platform.service; this.characteristic = platform.characteristic; // Set maximum and minimum volume, using defaults if not provided this.maxVolume = this.device.maxVolume || platform.config.maxVolume || this.maxVolume; this.minVolume = this.device.minVolume || platform.config.minVolume || this.minVolume; if (this.maxVolume > 100) { this.maxVolume = 100; } if (this.maxVolume < 20) { this.maxVolume = 20; } if (this.minVolume > this.maxVolume) { this.minVolume = this.maxVolume - 20; } if (this.minVolume < 0) { this.minVolume = 0; } while (this.maxVolume - this.minVolume < 20) { if (this.maxVolume + 1 < 100) { this.maxVolume++; } if (this.minVolume - 1 > 0) { this.minVolume--; } } // Initialize the default state object for the AVR this.state = { volume: 30, on: false, muted: true, input: 0, listeningMode: null, listeningModeLM: null, lastGetPowerStatus: null, }; // Log initialization this.log.debug('Initializing Pioneer AVR with accessory:', accessory.name); // Set default callback if none is provided if (typeof pioneerAvrClassCallback !== 'function') { pioneerAvrClassCallback = () => __awaiter(this, void 0, void 0, function* () { this.log.debug('PioneerAvr() connection ready'); }); } this.pioneerAvrClassCallback = pioneerAvrClassCallback; // Call setupTelnetConnection to initialize Telnet connection if (typeof this.setupTelnetConnection === 'function') { this.setupTelnetConnection(); } else { this.log.debug('setupTelnetConnection function is missing.'); } } })))) { } // Export the class for use by the platform exports.default = PioneerAvr; //# sourceMappingURL=pioneerAvr.js.map