Hi @code_skin , thanks for your answer!
I thought about using system.alarm.queryStatus() but I’m not sure i can get all configured alarms with this. I think i can only get activeUnacked, activeAcked, clearUnacked, clearAcked …
So if an alarm never went active it won’t appear in the dataset
I found that using statusquery didn't get a full list. I don't think I ever was able to get a full list...
Or maybe I had to use system.tag.browse for it or the other config one?
In this example I am writing the results to a Dataset type tag, of course you can get more information / props if you need.
# This function was designed to run from a Gateway Scoped call. Client based calls (such as those triggered by a button press) should search in an asynchronous thread.
# Define the search as a function. This makes recursion easier.
def manualSearch(initPath):
# If troubleshooting, you could print out the initPath here
# Create a result set of just tags. This call could be modified to look for a specific sub of tags,
# such as just UDT instances
tagSet = system.tag.browseTags(parentPath = initPath, tagPath = '*',
recursive=False)
# Create a result set of just folders. We'll iterate over this set and call browseTags() again for the results.
folderSet = system.tag.browseTags(parentPath = initPath, tagPath = '*',
tagType = 'Folder',
recursive=False)
# Iterate through our folders...
for folder in folderSet:
# If troubleshooting, you also could print out folder.path here.
# ...And start the process over again until we run out of folders.
tagSet+=manualSearch(folder.fullPath)
# Return the list of tags.
return tagSet
# Call this on the manual tag provider. Change the intialPath here if searching through a specific Tag Provider.
myTags = manualSearch("[Sample_Tags]")
idx=0
headers=["ID","Alarm"]
data=[]
for myTag in myTags:
try:
tagDefs = system.tag.getAlarmStates(str(myTag))
for tagDef in tagDefs:
idx=idx+1
AlmDef= tagDef.alarm
data.append([idx,AlmDef])
except:
pass
print idx
AlmSet = system.dataset.toDataSet(headers, data)
system.tag.write("[Sample_Tags]AlmDefs",AlmSet)