I was mistaken: I thought there was a way to access which points had triggered the context update, but I see that I was incorrect.
To solve this, I would do the following:
- Create a meta point that is of type Numeric.
- Write a script, "return 0;" or use your method to initialize, return "p.past(YEAR,1).sum;"
- Run the script once or twice, so that the value of zero is recorded for the meta point. (use cron "0/1 * * * * ? *" to execute it every second it is enabled and record a value)
- Add the point you wish to aggregate to the context, call "p"
- Add the meta point itself to the context, call "m"
- Write a script, "return m.value + p.past(MINUTE,1).sum;"
- Have the meta point run on a Cron pattern, perhaps "0 * * * * ? *" for every minute
- Enable the point.
If one minute is not good enough time resolution, you can modify it to be .past(SECOND, 15) and modify the Cron pattern to be "0/15 * * * * ? *"
So long as the number you choose in place of "15" is a factor of 60 (1,2,3,4,5,6,10,12,15,20,30,60) you can use it in both places and get uniform data.