I have a datapoint that updates everytime a watthour is consumed. The value of this datapoint itself isn't relevant in this case, only the number of times it has been updated.
What I would like to do is to create a metapoint that will increment on every update so I have the total of consumed watthours. I can do that by putting the datapoint in the context so that the script will execute on an update.
If I want to increment the metapoint, I need to put the metapoint itself in the script context as well to to be able to access the current value. However that will trigger the script to be executed again when the script returns the incremented value, so that doesn't work.
Currently I use the count function from the statistics object returned by past() to get the job done, but that seems to iterate over all values everytime and thus takes a lot of work. That doesn't seem to be the right way.