UNPKG

homebridge-loxone-proxy

Version:

Homebridge Dynamic Platform Plugin which exposes a Loxone System to Homekit.

55 lines 2.68 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Intercom = void 0; const LoxoneAccessory_1 = require("../../LoxoneAccessory"); const Doorbell_1 = require("../../homekit/services/Doorbell"); const Switch_1 = require("../../homekit/services/Switch"); const Camera_1 = require("../../homekit/services/Camera"); class Intercom extends LoxoneAccessory_1.LoxoneAccessory { configureServices() { this.ItemStates = { [this.device.states.bell]: { 'service': 'PrimaryService', 'state': 'bell' }, }; this.Service.PrimaryService = new Doorbell_1.Doorbell(this.platform, this.Accessory); this.configureCamera(); this.registerChildItems(); } async configureCamera() { var _a, _b; const parsedData = await this.platform.LoxoneHandler.getsecuredDetails(this.device.uuidAction); const videoInfo = ((_a = parsedData === null || parsedData === void 0 ? void 0 : parsedData.LL) === null || _a === void 0 ? void 0 : _a.value) ? (_b = JSON.parse(parsedData.LL.value)) === null || _b === void 0 ? void 0 : _b.videoInfo : undefined; let streamUrl = 'undefined'; if (videoInfo === undefined) { this.platform.log.debug(`[${this.device.name}] Loxone Intercom without Camera`); return; } if (this.device.details.deviceType === 0) { streamUrl = videoInfo.streamUrl; } else if (videoInfo.alertImage) { const ipAddressMatch = videoInfo.alertImage.match(/\/\/([^/]+)/); const ipAddress = ipAddressMatch ? ipAddressMatch[1] : undefined; if (ipAddress) { streamUrl = `http://${ipAddress}/mjpg/video.mjpg`; } } const base64auth = Buffer.from(`${videoInfo.user}:${videoInfo.pass}`, 'utf8').toString('base64'); this.setupCamera(streamUrl, base64auth); } setupCamera(ipAddress, base64auth) { new Camera_1.Camera(this.platform, this.Accessory, ipAddress, base64auth); } registerChildItems() { for (const childUuid in this.device.subControls) { const ChildItem = this.device.subControls[childUuid]; const serviceName = ChildItem.name.replace(/\s/g, ''); for (const stateName in ChildItem.states) { const stateUUID = ChildItem.states[stateName]; this.ItemStates[stateUUID] = { service: serviceName, state: stateName }; this.Service[serviceName] = new Switch_1.Switch(this.platform, this.Accessory, ChildItem); } } } } exports.Intercom = Intercom; //# sourceMappingURL=Intercom.js.map