Ive got a script running as an event script on a time stamp the queries a DB 60 seconds ago and takes away the current value from the historical value. It works absolutely fine in script console but doesnt seem to do anything in the event script.. any ideas?
time=system.date.addMinutes(system.date.now(),-1)
sqltime=system.date.format(time,"YYYY-MM-dd HH:mm:ss")
sql="SELECT top(1) * FROM Pressure_History where Current_DateTime > '%s' "%sqltime
res=system.db.runQuery(sql)
pressure=res[0]['Pressure']
pressure = int(pressure)
currpress = system.tag.readBlocking("[default]Test/Pressure")[0].value
final = pressure - currpress
system.tag.writeAsync("[default]Test/Pressure diff 1 min",final)
print final