UNPKG

homebridge-loxone-proxy

Version:

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

58 lines 2.77 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LockMechanism = void 0; const BaseService_1 = require("./BaseService"); class LockMechanism extends BaseService_1.BaseService { constructor() { super(...arguments); this.State = { LockCurrentState: 0, LockTargetState: 0, }; this.updateService = (message) => { var _a; if ((_a = this.platform.config.switchAlias) === null || _a === void 0 ? void 0 : _a.ReverseLockSwitch) { message.value = message.value === 0 ? 1 : 0; } this.platform.log.debug(`[${this.device.name}] Callback state update for Lock: ${message.value}`); this.State.LockTargetState = message.value; this.service .getCharacteristic(this.platform.Characteristic.LockTargetState) .updateValue(this.State.LockTargetState); setTimeout(() => { this.State.LockCurrentState = message.value; this.service .getCharacteristic(this.platform.Characteristic.LockCurrentState) .updateValue(this.State.LockCurrentState); }, 6000); }; } setupService() { this.service = this.accessory.getService(this.platform.Service.LockMechanism) || this.accessory.addService(this.platform.Service.LockMechanism); this.service.getCharacteristic(this.platform.Characteristic.LockCurrentState) .onGet(this.handleLockCurrentStateGet.bind(this)); this.service.getCharacteristic(this.platform.Characteristic.LockTargetState) .onGet(this.handleLockTargetStateGet.bind(this)) .onSet(this.handleLockTargetStateSet.bind(this)); } handleLockCurrentStateGet() { this.platform.log.debug('Triggered GET LockCurrentState'); return this.State.LockCurrentState; } handleLockTargetStateGet() { this.platform.log.debug('Triggered GET LockTargetState'); return this.State.LockTargetState; } handleLockTargetStateSet(value) { var _a; this.platform.log.debug('Triggered SET LockTargetState:' + value); const reverse = (_a = this.platform.config.switchAlias) === null || _a === void 0 ? void 0 : _a.ReverseLockSwitch; const command = reverse ? (this.State.LockTargetState === 0 ? 'Off' : 'On') : (this.State.LockTargetState === 0 ? 'On' : 'Off'); this.platform.log.debug(`[${this.device.name}] - send message: ${command}`); this.platform.LoxoneHandler.sendCommand(this.device.uuidAction, command); } } exports.LockMechanism = LockMechanism; //# sourceMappingURL=LockMechanism.js.map