runScript Tag Expression Binding on system.tag.queryTagCalculations Function Failing to Return Values to Tag

I am trying to calculate an hourly average from one historical tag (Outlet Temp) and display it with another tag (Outlet Temp Avg). This is the code that I entered in the script console, and it worked:

def HourAverage(x):
endTime = system.date.now()
startTime = system.date.addMinutes(endTime, -60)
dataSet = system.tag.queryTagCalculations(paths=, startDate=startTime, endDate=endTime, returnSize=1, calculations=[“Average”], returnFormat=‘Wide’)
return dataSet.getValueAt(0,1)

HourAverage(“Outlet Temp”)

Now, this is the code I entered into my global script, identical to the script console:

def HourAverage(x):
endTime = system.date.now()
startTime = system.date.addMinutes(endTime, -60)
dataSet = system.tag.queryTagCalculations(paths=, startDate=startTime, endDate=endTime, returnSize=1, calculations=[“Average”,“Maximum”], returnFormat=‘Wide’)
return dataSet.getValueAt(0,1)

And this is the Outlet Temp Average expression binding:

runScript(“shared.HourAverage”,0,“Outlet Temp”)

I am getting confirmation that both the script console and the tag expression are returning 1x2 arrays, and that both of the (0,0) values are the same “Outlet Temp”. However, the script console and tag expression differ in the (0,1) position, where the tag expression returns a null value. Any ideas of what’s going wrong?

Project Libary Script cannot be called from the Gateway Scope, of which Tag are a part of. You can read more about this here.

Do your paths have the tag provider specified? There’s no default tag provider in global scope.

1 Like