What am I doing wrong here? I have this global script that gets called by a gateway tag change script. what I am trying to add is the tag quality to the script, to verify that I have good quality before inserting a record. I am seeing duplicate records when a device loses comms so I figure that if I look at the quality before doing the insert, I should be ok. Ive tried doing “Good” and also 192, but neither work.
[code]def alarmChange(deviceName, newValue):
import system, app
result = system.db.runPrepQuery("SELECT id FROM compdevices WHERE poll = 1 AND devicename = ?", [deviceName])
if len(result):
deviceId = result[0][0]
tagQuality = system.tag.getTagValue("%s/Comp_Stat.Quality" % (deviceName))
if newValue == 1 and tagQuality == "Good":
system.db.runPrepUpdate("INSERT INTO comphistory (compid, startalarmdate) VALUES (?, CURRENT_TIMESTAMP)", [deviceId])
else:
system.db.runPrepUpdate("UPDATE comphistory SET endalarmdate = CURRENT_TIMESTAMP WHERE compid = ? AND endalarmdate IS NULL", [deviceId])[/code]