Coder Social home page Coder Social logo

Comments (7)

simont77 avatar simont77 commented on August 18, 2024

There is no loader and what you ask is not an included functionality. You may try using the “private” _addEntry function instead of the “public” addEntry, this would bypass timers and averages, but I cannot guarantee that it would work with no issue.

from fakegato-history.

ebaauw avatar ebaauw commented on August 18, 2024

Did you have a look at the persist files that fakagato-storage creates? I image it would be relatively easy to write a small programme that converts your log file to the proper json, so fakegato storage can simply load it on startup.

from fakegato-history.

mylesagray avatar mylesagray commented on August 18, 2024

from fakegato-history.

mylesagray avatar mylesagray commented on August 18, 2024

Just to let you know I've used the private _addEntry() method and it worked beautifully,

For reference, this.historicalmeasurements is a 2D array formatted as such:

[
  [timestamp]
  [particular matter density]
  [temperature]
  [humidity]
  [co2 in ppm]
  [voc]
  [all pollution as a %]
]

Each value at a particular position in the 2D array directly correlates to the other values at that same position, for example: this.historicalmeasurements[0][123] and this.historicalmeasurements[3][123] were measured at the same time. So when I iterate over the array passing the loop number, I know that all characteristics correlate:

//Load historicals from API into Elgato
for (var i = 0; i < this.historicalmeasurements[0].length; i++){
  this.loggingService._addEntry({
    time: this.historicalmeasurements[0][i],
    temp: this.historicalmeasurements[2][i],
    humidity: this.historicalmeasurements[3][i],
    ppm: this.historicalmeasurements[4][i]
  });
}

Just going to add some safety barriers around it so it only adds to the history once before I commit it to my plugin, current working version can be seen here: mylesagray/homebridge-blueair@811421e

https://dl.dropboxusercontent.com/s/kvge7vu3hsf40ss/Photo%2007-03-2018%2C%2000%2045%2003.png?dl=0

from fakegato-history.

mylesagray avatar mylesagray commented on August 18, 2024

Trying to refine this a bit, I have reverted to using the public addEntry() method and just setting disableTimer:true in the setup.

It downloads all values and pushes them in fine - but there seems to be a strange behaviour when it saves to the persistence file - like there are many, many processes all editing the same file at once.

Does the public (or even private) addEntry() method not wait until the file has been successfully written to before returning?

It seems like what is happening upon the initial ingestion of data that the file is written fully, but then there are n number of save processes queued, one for each addEntry call and these all need to execute before it pushes the history to the Eve app?

This behaviour would probably also occur even if a few entries were pushed to addEntry in quick succession.

from fakegato-history.

simont77 avatar simont77 commented on August 18, 2024

Are you pushing data with addEntry with a short delay? All the persistence stuff was designed assuming a rate of al least few seconds. I cannot exclude some glitch if the rate is much faster. However @NorthernMan54 is working on an event based persistence that I hope should fix all this race related issues.

from fakegato-history.

mylesagray avatar mylesagray commented on August 18, 2024

@simont77 No delay at all, just dumping the data in as fast as the loop executes. Event based persistence would be awesome, glad to hear there is something in the works for this, backfilling histories would be cool for a few plugins i'm using but at the moment I can't work around the problems without editing fakegato-history itself.

from fakegato-history.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.