-
Hallo, type: custom:plotly-graph
entities:
- entity: sensor.gasincubicmeter
name: täglicher Gasverbrauch
show_value: true
type: bar
statistic: state
period: day
texttemplate: ' %{y:.2f} m³'
filters:
- fn: |-
({ys , xs}) => {
const DAY= 24*60*60*1000;
let today= xs[0] - (xs[0].getTime() % DAY)
+60*1000* new Date().getTimezoneOffset();
const result = {x:[], y:[]}
let last= parseFloat(ys[0]);
let tomorrow= today + DAY;
let firstday= today;
let x,y
for (let i = 0; i < xs.length; i+=1) {
x = xs[i]
y = parseFloat(ys[i])
if (x>tomorrow){
if (firstday != today) {
result.y.push(y-last)
result.x.push(new Date(today))
}
last = y
today= tomorrow
tomorrow+= DAY
}
}
result.y.push(y-last)
result.x.push(new Date(today))
return result
}
- filter: i>0
refresh_interval: 10
hours_to_show: 4d |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
If I interpret the lambda correctly, this is computing the delta (or derivative in day units). Just do: filters:
- delta otherwise, just change |
Beta Was this translation helpful? Give feedback.
-
If that's not enough let me know and I'll test/debug it myself. I suggest you also take a look at the filters section of the readme you may get some ideas for this or other plots, these are fun to compose together :) |
Beta Was this translation helpful? Give feedback.
If I interpret the lambda correctly, this is computing the delta (or derivative in day units). Just do:
otherwise, just change
result.x
andresult.y
toresult.xs
andresult.ys
. And this too:const result = {xs:[], ys:[]}