UNPKG

homebridge-loxone-proxy

Version:

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

39 lines 1.99 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.IntercomV2 = void 0; const Intercom_1 = require("./Intercom"); const MotionSensor_1 = require("../../homekit/services/MotionSensor"); const Camera_1 = require("../../homekit/services/Camera"); class IntercomV2 extends Intercom_1.Intercom { async configureCamera() { let isConfigured = false; this.platform.LoxoneHandler.registerListenerForUUID(this.device.states.address, (ip) => { if (isConfigured) { return; } this.platform.log.debug(`[${this.device.name}] Found Loxone Intercom on IP: ${ip}`); this.camera = new Camera_1.Camera(this.platform, this.Accessory, `http://${ip}/mjpg/video.mjpg`); this.configureMotionSensor(); isConfigured = true; }); } async configureMotionSensor() { const targetUuidPrefix = this.device.details.deviceUuid.split('-')[0]; const intercomMotionUuid = Object.keys(this.platform.LoxoneItems).filter(uuid => uuid.startsWith(targetUuidPrefix)); if (intercomMotionUuid.length > 0) { const matchingDevice = this.platform.LoxoneItems[`${intercomMotionUuid}`]; this.platform.log.debug(`[${this.device.name}] Found Loxone IntercomV2 MotionSensor`); const serviceName = matchingDevice.name.replace(/\s/g, ''); for (const stateName in matchingDevice.states) { const stateUUID = matchingDevice.states[stateName]; this.ItemStates[stateUUID] = { service: serviceName, state: stateName }; this.Service[serviceName] = new MotionSensor_1.MotionSensor(this.platform, this.Accessory, matchingDevice, this.camera); } } else { this.platform.log.debug(`[${this.device.name}] Unable to find Loxone IntercomV2 MotionSensor`); } } } exports.IntercomV2 = IntercomV2; //# sourceMappingURL=IntercomV2.js.map