Flatline fix for Sensor Cards#2064
Flatline fix for Sensor Cards#2064balloob merged 6 commits intohome-assistant:devfrom Petro31:patch-2
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.