Improve sensor graph algorithm #2069
Merged
+74
−49
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As discussed in #2064
The current calculation of the graph is flawed, the data points are just spread out over the x-axis and doesn't take the actual time of the history entry into account. Works fairly well for sensors that update regularly but not for sensors that updates sporadically or sensors that fluctuate a lot.
This PR includes a rework of the graph calculation algorithm which now calculates the data points based on time and plots them out accordingly. Would have to replace the accuracy option with something like detail: 1 or 2, 1 for one point every hour, 2 for one point every 10 minute.
The new implementation will also assign the data points with a moving average for that hour/ten minutes, instead of just the value of a single history entry, which should result in a better representation of the actual history.
Should solve these issues:
#2038
#2010