Here is how I calculate average rain every 15 minutes in the past 2 hours;
configuration: {}
triggers:
- id: "2"
configuration:
cronExpression: 0 0/15 * * * ? *
type: timer.GenericCronTrigger
conditions: []
actions:
- inputs: {}
id: "1"
configuration:
type: application/vnd.openhab.dsl.rule
script: >-
var work = OU_Weather_Actual_Rain
OU_Weather_Actual_Rain_avg.postUpdate(work.averageSince(now.minusMinutes(120))as Number)
type: script.ScriptAction
Hope this helps.