thanks for the quick reply.
Ok let me get this correct. influxdb can sum it up and i can then query this value in OH in a widget or so?
I not getting the complete picture yet.
Can you give me a bit more details if possible? Maybe your broken code and how i would then display the calculated value in OH.
Please be aware, that summing up is not what you are actually looking for, you want to calculate the Integral.
Anyhow. Yes, InfluxDB can integrate over a measurement series. The query can be called from Grafana, from command line or via REST Api call. So you can either generate a graph in Grafana or retrieve values through the REST API from within an openHAB rule (or via the HTTP binding).
I did never implement the latter but would be interested in a solution and would happily add it to the InfluxDB+Grafana tutorial. Kepp us posted! @rlkoshak might have additional experience in this area.
Edit: Just found the issue on my side: INTEGRAL was introduced in InfluxDB 1.3
A long time ago I remember helping @sipvoip with some rules to calculate running totals of power usage (i.e. last day, last week, last month) but in that case, I’m pretty certain that he was getting kWh so didn’t need to do the integral himself.
Maybe he remembers and can find the thread and/or can post his code.
That being said, I would look into Grafana and InfluxDB as a way to do this. InfluxDB has a REST API so it isn’t too hard to implement queries in rules.
InfluxDB has Integral but grafana somehow only let us use the default value 1s.
So i just integrate the value for 1s and cumulative_sum them after that devide it by 3600 to get hours.
The time interval has also to be set to 1s.
In the math field also the price calculation could be added.
Unfortunatly the starting point of the sumation is always the left border.
Anyone been able to get this to work on the singlestat widget? I’ve got it working on a graph like you demonstrated Josar, but I’d like a singlestat widget just to show the totals for the day so far. For a 24 hour period, yes, but if you wan’t ‘Today so far’, it’s not working it out correctly.