sorry, but I’m a bit stuck in getting the following implemented in a rule: I have a smart meter in my house of which I every day get the state at midnight and store it in a number item (so if I use 20kWh per day, then it’s for 5 days 20, 40, 60, 80, 100). With lastState and state I manage to calculate the daily delta of my energy consumption.
Yet, I would like to calculate the per day average over the last year but there I am stuck. Is there a way, to get the last 365 values of my daily delta item? These I would sum up then and divide by 365. But I have no idea, how to get those 365 values and sum them up in a variable.
If anybody could help, that would be very nice and thanks for any hint in advance.
But for real, how do you store your data? MySQL, InfluxDB yada yada.
Do you want to make this calculation multiple times a Day/Week/Year?
I would simply create a small Python3 script which gets the data calculates what I want, send it via. REST API to openHAB to a new “Yearly Energy Average item” which would be persisted again.
Or when using InfluxDB and Grafana just create a graph with what you want