fakegato-history
Advanced tools
Comparing version 0.4.1 to 0.4.2
@@ -0,1 +1,5 @@ | ||
### v0.4.2 | ||
- fix bug when internal timer is not enabled | ||
- add optional parameter for filename | ||
### v0.4.1 | ||
@@ -2,0 +6,0 @@ - fix filesystem persist location when -U option is used in homebridge |
@@ -155,2 +155,3 @@ /*jshint esversion: 6,node: true,-W041: false */ | ||
this.path = optionalParams.path || optionalParams.folder || (this.storage == 'fs' ? homebridge.user.storagePath() : undefined); | ||
this.filename = optionalParams.filename | ||
this.disableTimer = optionalParams.disableTimer || false; | ||
@@ -162,11 +163,11 @@ } else { | ||
} | ||
thisAccessory = accessory; | ||
this.accessoryName = thisAccessory.displayName; | ||
this.log = thisAccessory.log || {}; | ||
if (!this.log.debug) { | ||
this.log.debug = function() {}; | ||
} | ||
if(!this.disableTimer) { | ||
@@ -179,3 +180,3 @@ if (homebridge.globalFakeGatoTimer === undefined) | ||
} | ||
if(this.storage !== undefined) { | ||
@@ -191,5 +192,6 @@ this.loaded=false; | ||
path: this.path, | ||
filename: this.filename, | ||
keyPath: optionalParams.keyPath || homebridge.user.storagePath() || undefined, | ||
onReady:function(){ | ||
this.load(function(err,loaded){ | ||
@@ -207,4 +209,4 @@ //this.log.debug("Loaded",loaded); | ||
} | ||
switch (accessoryType) { | ||
@@ -219,3 +221,3 @@ case TYPE_WEATHER: | ||
var timer = params.timer; | ||
var fakegato = this.service; | ||
@@ -244,3 +246,3 @@ var calc = { | ||
calc.avrg.time = moment().unix(); // set the time of the avrg | ||
for (let key in previousAvrg) { // each record of previous average | ||
@@ -255,3 +257,3 @@ if (previousAvrg.hasOwnProperty(key) && key != 'time') { // except time | ||
} | ||
if(Object.keys(calc.avrg).length > 1) { | ||
@@ -273,3 +275,3 @@ fakegato._addEntry(calc.avrg); | ||
var timer = params.timer; | ||
var fakegato = this.service; | ||
@@ -298,3 +300,3 @@ var calc = { | ||
calc.avrg.time = moment().unix(); // set the time of the avrg | ||
for (let key in previousAvrg) { // each record of previous average | ||
@@ -309,3 +311,3 @@ if (previousAvrg.hasOwnProperty(key) && key != 'time') { // except time | ||
} | ||
fakegato._addEntry(calc.avrg); | ||
@@ -325,3 +327,3 @@ timer.emptyData(fakegato); | ||
var timer = params.timer; | ||
var fakegato = this.service; | ||
@@ -350,3 +352,3 @@ var calc = { | ||
calc.avrg.time = moment().unix(); // set the time of the avrg | ||
for (let key in previousAvrg) { // each record of previous average | ||
@@ -361,3 +363,3 @@ if (previousAvrg.hasOwnProperty(key) && key != 'time') { // except time | ||
} | ||
if(Object.keys(calc.avrg).length > 1) { | ||
@@ -378,3 +380,3 @@ fakegato._addEntry(calc.avrg); | ||
var immediate = params.immediate; | ||
var fakegato = this.service; | ||
@@ -406,3 +408,3 @@ var actualEntry={}; | ||
var immediate = params.immediate; | ||
var fakegato = this.service; | ||
@@ -447,3 +449,3 @@ var actualEntry={}; | ||
this.saving=false; | ||
this.registerEvents(); | ||
@@ -454,3 +456,3 @@ if(this.storage === undefined) { | ||
} | ||
registerEvents() { | ||
@@ -461,3 +463,3 @@ this.log.debug('Registring Events',thisAccessory.displayName); | ||
this.log.debug('Platform',thisAccessory.displayName); | ||
this.service = thisAccessory.getService(FakeGatoHistoryService); | ||
@@ -511,6 +513,11 @@ if (this.service === undefined) { | ||
else | ||
this._addEntry(entry); | ||
this._addEntry({time: entry.time, status: entry.status}); | ||
break; | ||
case TYPE_WEATHER: | ||
case TYPE_ROOM: | ||
if(!this.disableTimer) | ||
homebridge.globalFakeGatoTimer.addData({entry: entry, service: this}); | ||
else | ||
this._addEntry({time: entry.time, temp: entry.temp, humidity: entry.humidity, pressure: entry.pressure}); | ||
break; | ||
case TYPE_ENERGY: | ||
@@ -520,3 +527,3 @@ if(!this.disableTimer) | ||
else | ||
this._addEntry(entry); | ||
this._addEntry({time: entry.time, power: entry.power}); | ||
break; | ||
@@ -536,3 +543,3 @@ default: | ||
.bind(this); | ||
var val; | ||
@@ -580,7 +587,7 @@ | ||
numToHex(swap32(this.firstEntry+1), 8)); | ||
} | ||
} | ||
if (this.service === undefined) { // Accessory API | ||
this.getCharacteristic(S2R1Characteristic).setValue(hexToBase64(val)); | ||
} | ||
} | ||
else { // Platform API | ||
@@ -594,3 +601,3 @@ this.service.getCharacteristic(S2R1Characteristic).setValue(hexToBase64(val)); | ||
this.log.debug("116 %s: %s", this.accessoryName, val); | ||
if(this.storage !== undefined) this.save(); | ||
@@ -600,3 +607,3 @@ } else { | ||
this._addEntry(entry); | ||
}.bind(this),100); | ||
}.bind(this),100); | ||
} | ||
@@ -618,4 +625,4 @@ } | ||
}; | ||
homebridge.globalFakeGatoStorage.write({ | ||
@@ -629,3 +636,3 @@ service: this, | ||
this.save(); | ||
}.bind(this),100); | ||
}.bind(this),100); | ||
} | ||
@@ -643,3 +650,3 @@ } | ||
let jsonFile = typeof(data) === "object" ? data : JSON.parse(data); | ||
this.firstEntry = jsonFile.firstEntry; | ||
@@ -670,3 +677,3 @@ this.lastEntry = jsonFile.lastEntry; | ||
} | ||
getCurrentS2R2(callback) { | ||
@@ -680,3 +687,3 @@ var entry2address = function(val) { | ||
if ((this.history[this.memoryAddress].setRefTime == 1) || (this.setTime == true)) { | ||
var val = Format( | ||
@@ -683,0 +690,0 @@ '15%s 0100 0000 81%s0000 0000 00 0000', |
@@ -44,3 +44,3 @@ /*jshint esversion: 6,node: true,-W041: false */ | ||
'storage' : params.storage || 'fs', | ||
'fileName': hostname+"_"+service.accessoryName+fileSuffix // Unique filename per homebridge server. Allows test environments on other servers not to break prod. | ||
'fileName': params.filename || hostname+"_"+service.accessoryName+fileSuffix // Unique filename per homebridge server. Allows test environments on other servers not to break prod. | ||
}; | ||
@@ -47,0 +47,0 @@ var onReady = typeof(params.onReady) == 'function' ? params.onReady:function(){}.bind(this); |
{ | ||
"name": "fakegato-history", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "Module emulating Elgato Eve history for homebridge plugins", | ||
@@ -5,0 +5,0 @@ "main": "fakegato-history.js", |
60843
1368