Issue of the topic: I have searched for how to use the built-in rr4dj persistence to create an Item that contains the trailing 5-minute average of a value coming from a channel.
How can I do this simply? Step by step if possible? I am a noob!
UPDATE:
The answer by moody_blue works. Step by step:
Create item that records the high-frequency value (OU_Weather_Actual_Rain)
Create item that stores the average value (OU_Weather_Actual_Rain_avg)
Copy paste the solution and change cron expression, names, and numbers to match your system.
You might need to think a bit more about when to trigger the rule to run the calculation. The Item won’t necessarily change every … well, how often do you want it calculated, exactly? Decision for you.
The number of points averaged will depend on how often your Item is persisted.
The only things missing are to set up an Item to hold the average before going through your steps.
Your call is also missing a “)” at the end.
Alas, even after doing both of those, this doesn’t work for me. I also tried removing the tostring part and adding “rrd4j” as the second argument to averageSince.
I don’t know what the system defaults are, they didn’t make it to the docs. Sounds about right. Default may include onChange as well, (which would be helpful in your case).
You can interrogate the persistence for raw records using REST API Explorer, for rrd4j use a period like 1 hour to get to look in the ‘recent’ archive. See what’s there.
That sentence contains infinities. How specifically does it not work? Errors in the log? As @rossko57 suggested, add a logging statement to log out the result of the call to get the average.