UNPKG

homebridge-loxone-proxy

Version:

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

69 lines 3.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GarageDoorOpener = void 0; const BaseService_1 = require("./BaseService"); class GarageDoorOpener extends BaseService_1.BaseService { constructor() { super(...arguments); this.State = { CurrentDoorState: 0, TargetDoorState: 0, ObstructionDetected: 0, Active: 0, Position: 0, }; } setupService() { this.service = this.accessory.getService(this.platform.Service.GarageDoorOpener) || this.accessory.addService(this.platform.Service.GarageDoorOpener); this.service.getCharacteristic(this.platform.Characteristic.CurrentDoorState) .onGet(() => this.handleCurrentDoorStateGet()); this.service.getCharacteristic(this.platform.Characteristic.TargetDoorState) .onGet(() => this.handleTargetDoorStateGet()) .onSet((value) => this.handleTargetDoorStateSet(value)); this.service.getCharacteristic(this.platform.Characteristic.ObstructionDetected) .onGet(() => this.handleObstructionDetectedGet()); } updateService(message) { var _a, _b, _c, _d; this.platform.log.debug(`[${this.device.name}] ${message.state} Callback state update for Gate: ${message.value}`); (message.state) === 'active' ? this.State.Active = message.value : this.State.Position = message.value; switch (this.State.Active) { case -1: this.State.CurrentDoorState = 3; this.State.TargetDoorState = 1; break; case 0: this.State.CurrentDoorState = this.State.Position === 0 ? 1 : this.State.Position === 1 ? 0 : 4; this.State.TargetDoorState = this.State.Position === 0 ? 1 : 0; break; case 1: this.State.CurrentDoorState = 2; this.State.TargetDoorState = 0; break; } (_b = (_a = this.service) === null || _a === void 0 ? void 0 : _a.getCharacteristic(this.platform.Characteristic.CurrentDoorState)) === null || _b === void 0 ? void 0 : _b.updateValue(this.State.CurrentDoorState); (_d = (_c = this.service) === null || _c === void 0 ? void 0 : _c.getCharacteristic(this.platform.Characteristic.TargetDoorState)) === null || _d === void 0 ? void 0 : _d.updateValue(this.State.TargetDoorState); } handleCurrentDoorStateGet() { this.platform.log.debug('Triggered GET CurrentDoorState'); return this.State.CurrentDoorState; } handleTargetDoorStateGet() { this.platform.log.debug('Triggered GET TargetDoorState'); return this.State.TargetDoorState; } handleTargetDoorStateSet(value) { this.platform.log.debug('Triggered SET TargetDoorState: ' + value); this.State.TargetDoorState = value; const command = value === 0 ? 'open' : 'close'; this.platform.LoxoneHandler.sendCommand(this.device.uuidAction, command); } handleObstructionDetectedGet() { this.platform.log.debug('Triggered GET ObstructionDetected'); return this.State.ObstructionDetected; } } exports.GarageDoorOpener = GarageDoorOpener; //# sourceMappingURL=GarageDoorOpener.js.map