diff --git a/api.js b/api.js index d61a976..dd12ca2 100644 --- a/api.js +++ b/api.js @@ -272,8 +272,8 @@ AirtouchAPI.prototype.connect = function(address) { // request information from Airtouch after connection setTimeout(this.GET_AC_STATUS.bind(this), 0); setTimeout(this.GET_GROUP_STATUS.bind(this), 2000); - // schedule group status every 5 minutes to get updates for FakeGato history service - setInterval(this.GET_GROUP_STATUS.bind(this), 300000); + // schedule group status every 4.75 minutes to get updates for FakeGato history service + setInterval(this.GET_GROUP_STATUS.bind(this), 285000); }); this.device.on("close", () => { this.log("API | Disconnected from Airtouch"); diff --git a/index.js b/index.js index 20ea5ff..d83c068 100644 --- a/index.js +++ b/index.js @@ -225,6 +225,7 @@ Airtouch.prototype.setupACAccessory = function(accessory) { thermostat.isPrimaryService = true; accessory.historyService = new FakeGatoHistoryService("thermo", accessory, { storage: "fs" }); + accessory.historyUpdate = 0; this.log("Finished creating accessory [" + accessory.displayName + "]"); }; @@ -259,12 +260,16 @@ Airtouch.prototype.updateACAccessory = function(accessory, status) { thermostat.setCharacteristic(Characteristic.RotationSpeed, accessory.context.rotationSpeed); // save history as Eve Thermo - accessory.historyService.addEntry({ - time: new Date().getTime() / 1000, - currentTemp: accessory.context.currentTemperature, - setTemp: accessory.context.targetTemperature, - valvePosition: accessory.context.rotationSpeed - }); + let now = new Date().getTime() / 1000; + if (now - accessory.historyUpdate > 285) { // 285s = 4.75 min update intervals + accessory.historyService.addEntry({ + time: now, + currentTemp: accessory.context.currentTemperature, + setTemp: accessory.context.targetTemperature, + valvePosition: accessory.context.rotationSpeed + }); + accessory.historyUpdate = now; + } accessory.context.statusFault = status.ac_error_code; thermostat.setCharacteristic(Characteristic.StatusFault, accessory.context.statusFault);