-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Flatline fix for Sensor Cards #2064
Conversation
This fixes issues where the first history item was repeated many times at the start of the graph resulting in a flat line that does not represent the data. Also, the graph now has the ability to reach a 1 to 1 history graph to sensor graph point representation. Before 2 to 1 was the highest resolution possible. This was due to using history.length - 1 as the denominator in cases where the user set the accuracy larger than the total number of points in the history.
@kalkih , does this make sense? |
Yes, this should solve the issue when there are fewer history entries than the accuracy set. 👍 There are more issues with the current calculation of the line though, 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. I pretty much did a rewrite of the algorithm which now calculates the data points based on time and plots them out accordingly. Would have to replace the Edit: The new implementation would 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. Let me know if you want me to open a PR for this. |
I would love for a PR that makes it better 👍 would that supersede this PR ? |
@balloob, @kalkih I can do the other PR that fixes the algorithm. But as you can probably tell from my commits, I don't have a dev environment. I made the changes in the custom card and placed them here. I got a new system coming in the mail today and I'll have a dev environment setup within the next week. When that happens, I can make a better PR if you guys do not have the time. I didn't want to make major changes without being able to fully test inside the suite. This PR was encapsulated in 1 function that had the same variables names. I was confident this would work no matter what. |
Will merge this and @kalkih can open a better PR when ready. |
This fixes issues where the first history item was repeated many times at the start of the graph resulting in a flat line that does not represent the data.
Also, the graph now has the ability to reach a 1 to 1 history graph to sensor graph point representation. Before 2 to 1 was the highest resolution possible. This was due to using history.length - 1 as the denominator in cases where the user set the accuracy larger than the total number of points in the history.