homebridge-loxone-proxy
Version:
Homebridge Dynamic Platform Plugin which exposes a Loxone System to Homekit.
34 lines • 1.55 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MotionSensor = void 0;
const BaseService_1 = require("./BaseService");
class MotionSensor extends BaseService_1.BaseService {
constructor(platform, accessory, device) {
super(platform, accessory, device);
this.State = {
MotionDetected: false,
};
this.updateService = (message) => {
if (message.value !== 0 && message.value !== 1) {
this.platform.log.debug(`[${this.device.name}] Ignored message value: ${message.value}`);
return;
}
this.platform.log.debug(`[${this.device.name}] Callback state update for MotionSensor: ${!!message.value}`);
this.State.MotionDetected = !!message.value;
this.service.getCharacteristic(this.platform.Characteristic.MotionDetected).updateValue(this.State.MotionDetected);
};
this.setupService();
}
setupService() {
this.service = this.accessory.getService(this.platform.Service.MotionSensor) ||
this.accessory.addService(this.platform.Service.MotionSensor);
this.service.getCharacteristic(this.platform.Characteristic.MotionDetected)
.onGet(this.handleMotionDetectedGet.bind(this));
}
handleMotionDetectedGet() {
this.platform.log.debug(`[${this.device.name}] Triggered GET MotionDetected`);
return this.State.MotionDetected;
}
}
exports.MotionSensor = MotionSensor;
//# sourceMappingURL=MotionSensor.js.map