-
-
Notifications
You must be signed in to change notification settings - Fork 24
Add refresh_interval: auto #114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
dup.last_updated = Math.min(+end, Date.now()); | ||
history.push(dup); | ||
range = [startT, history[history.length - 1].timestamp]; | ||
history[0].fake_boundary_datapoint = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zanna-37 I was doing something else, but it required me to review the code that handles the invented points.
I had remembered it incorrectly and thought HA sent a fake datapoint at the end of the requested interval. Instead (and I think you mentioned this already), HA sends a fake datapoint at the start of the requested interval.
What I did as part of this WIP PR seems to work really well:
- Fetch from
startT-1
: this way the first datapoint is either fake, or irrelevant for the requested range. - Mark it for deletion (which will only happen if the datapoint is not the first one in the cache)
- And then (this is below), when clearing old data from the cache, don't modify the first and last datapoints so they match the visible range. Instead, leave them as they are. This is now possible because the visible range is now set explicitely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you mean by "clearing old data from the cache"? When does this happen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This happens when one is not "browsing" i.e if one doesn't zoom/scroll or after clicking reset. To avoid accumulating datapoints in ram for ever, the caches is cleared of all data out of the hours_to_show
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also changed how the traces are extended to the present: Instead of doing it inside of the cache, the extra datapoint is only created during plotting. This means that there is nothing to manage or remove later, as far as the cache is concerned, those "fake" points don't exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, well done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that now that the axis rang is set explicitly, there's no need for it to be this aggressive
8690682
to
44fb86e
Compare
…nge is already cached
Update reactively when an entity changes its state.