-
UPDATE: Be sure to look at the finalized code in the responses. My next challenge is to make a chart which calculates the difference of a value between periods of time. The Home Assistant statistics card supports choosing to show the difference using the 'diff' option, but that option doesn't seem to work in a Plotly graph. I have created a basic Plotly card which now shows the total usage of my internet data, which it is calculating as ever increasing... This is a fairly basic card which is relatively easy to create. My YAML for this is as follows...
For me, the data consumption is a "fun fact", but for those with metered connections, this could be incredibly useful information. In order for this to be useful, I need to modify it two ways in which I need direction. First, Home Assistant supports long term statistics being displayed as a difference from period to period. So, for example, I would want each monthly bar to represent the difference from the previous month. It doesn't seem as though ' diff ' directly translates to a Plotly card, although I'm sure there is a pretty straightforward means to do it. Would this be a function? Second, I would like the values on the axis to be converted to GB. The PFSense integration's sensor reports the total in bytes, but the value just displays a ridiculously long and uninformative number. In a perfect world I'd define periods, something like...
But in this case, I'm happy with monthly as a start. What is the proper way to implement a 'difference' in this situation? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
Welcome to Filters. Look specifically at the delta filter. I suggest you take a look at all of them to get new ideas for processing your data |
Beta Was this translation helpful? Give feedback.
-
I found from examples that if I add the following to each entity, the conversion part seems to work. If this looks rational to convert bytes to GB?
After two hours of trying, I'm copping out for the night. LOL The delta thing is baffling me. Any nudge in the right direction on that would be appreciated. I understand it specifies the difference somehow, but not much else at the moment. |
Beta Was this translation helpful? Give feedback.
-
Current results... |
Beta Was this translation helpful? Give feedback.
-
Actually, I think I'm leaving the code here... Monthly totals are all that seem relevant in this context.
|
Beta Was this translation helpful? Give feedback.
The delta computes the delta between each two consecutive numeric y values
So if your sensor has 10 in December and 15 in Jan, the delta filter will give you 5 in Jan (the difference between Jan and Dec)