@pst-on-npm/homebridge-enocean
Version:
Integrate EnOcean® devices into Homebridge.
51 lines • 1.93 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.fakegatoCharacteristicsExample = exports.CustomCharacteristics = void 0;
class CustomCharacteristics {
_api;
_lastActivation;
constructor(api) {
this._api = api;
}
get LastActivation() {
if (this._lastActivation === undefined) {
this._lastActivation = new this._api.hap.Characteristic('LastActivation', 'E863F11A-079E-48FF-8F27-9C2605A29F52', {
format: "uint32" /* this._api.hap.Formats.UINT32 */,
perms: ["pr" /* this._api.hap.Perms.PAIRED_READ */],
});
}
return this._lastActivation;
}
}
exports.CustomCharacteristics = CustomCharacteristics;
class fakegatoCharacteristicsExample {
service;
customCharacteristics;
_lastActivation;
_state;
constructor(service, customCharacteristics) {
this.service = service;
this.customCharacteristics = customCharacteristics;
this._lastActivation = Math.floor(Date.now() / 1000);
this._state = 0;
}
// fakegato characteristics
addFakegatoCharacteristics(historyService) {
let c = this.service.getCharacteristic('LastActivation');
if (c === undefined) {
c = this.service.addCharacteristic(this.customCharacteristics.LastActivation);
}
c.onGet(async () => {
let time = historyService.getInitialTime();
if (time === undefined) {
const entry = { time: this._lastActivation, status: this._state };
historyService.addEntry(entry);
}
time = this._lastActivation - historyService.getInitialTime();
console.log('GET LAST ACTIVATION', time);
return time;
});
}
}
exports.fakegatoCharacteristicsExample = fakegatoCharacteristicsExample;
//# sourceMappingURL=CustomCharacteristics.js.map