homebridge-loxone-proxy
Version:
Homebridge Dynamic Platform Plugin which exposes a Loxone System to Homekit.
37 lines • 1.62 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Doorbell = void 0;
const BaseService_1 = require("./BaseService");
class Doorbell extends BaseService_1.BaseService {
constructor(platform, accessory) {
super(platform, accessory);
this.State = {
ProgrammableSwitchEvent: 0,
};
this.setupService();
}
setupService() {
this.service = this.accessory.getService(this.platform.Service.Doorbell) ||
this.accessory.addService(this.platform.Service.Doorbell);
this.service.getCharacteristic(this.platform.Characteristic.ProgrammableSwitchEvent)
.onGet(() => this.handleProgrammableSwitchEventGet());
}
triggerDoorbell() {
var _a;
this.platform.log.info(`[${this.device.name}] 🔔 Doorbell event triggered`);
this.State.ProgrammableSwitchEvent = this.platform.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS;
(_a = this.service) === null || _a === void 0 ? void 0 : _a.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchEvent, this.State.ProgrammableSwitchEvent);
}
updateService(message) {
this.platform.log.debug(`[${this.device.name}] Callback state update for Doorbell: ${message.value}`);
if (message.value === 1) {
this.triggerDoorbell();
}
}
handleProgrammableSwitchEventGet() {
this.platform.log.debug('Triggered GET ProgrammableSwitchEvent');
return this.State.ProgrammableSwitchEvent;
}
}
exports.Doorbell = Doorbell;
//# sourceMappingURL=Doorbell.js.map