A tag average over time

What rate is the history being collected on Water Age Days? The script works in the script console and there is no reason it should not work in the gateway timer. Something seems amiss with the data, the only explanation is system.tag.queryTagHistory() is returning a blank dataset.

Unless there is something else writing to the tag which I find hard to believe if you created a new tag.

Go into your logs when the gateway script is running and check for errors

Like the actual gateway console logs?

You are still missing the tag provider here. Format your code when you paste it in the forum, so it can be read easier.
image

now = system.date.now()
startDate = system.date.addHours(now, -1)
endDate = now
avg = system.tag.queryTagHistory(paths=["[default]East Res/Water Age Days"], startDate=startDate, endDate=endDate, returnSize=1, aggregationMode="SimpleAverage")
system.tag.write("[default]East Res/Water Age Ave",avg.getValueAt (0,1))

Headbashes the desk

Forgive me, we have just been all over the loop with this code that I didn’t even see that.

And wouldn’t you know it

It finally

Freaking

Works!

Every six seconds (right now) if the average changes the tag number changes.

It’s been 3 minutes and so far it has not broken

Thank you all so so much.

3 Likes

I see you have it working but for future reference, yes, any errors from gateway scripts go to the gateway log files in the status section of the gateway

Ok I thought that’s what you were referencing but I wasn’t…100% sure.