system.tag.getAlarmStates alternative?

Old post, but still relevant issue… the issue here is that getConfiguration returns only non-default property values of tags, nothing more. For example, if you leave the alarm Priority at the default of Low, then this configuration will not show if you run getConfiguration. Therefore you need to use getConfiguration to get the name of the alarm, then you can use readBlocking to read the properties of the alarms you need.

The only way that I can see being able to use getConfiguration to help with this, is if you:

  1. use system.tag.browse to find all of the tags
  2. call system.tag.getConfiguration in a loop to get the configuration of each tag individually. check if it has an alarm and if so, store the alarm name in a list
  3. create a list or lists of the tag paths to the alarm properties that you want to read by appending to the alarm tags list created in (2) e.g. alarmPriorityTagPaths = [tagPath + '/Alarms/' + alarmName + '.Priority' for tagPath, alarmName in zip(tags, alarmNames)]
  4. use system.tag.readBlocking to read the values of the alarm properties list(s)

For 350k tags, I estimated this to take a solid 9hrs… extremely inefficient, but I don’t know any other way to do this…
For 450 tags it took 42s to do parts 1-2 above

import time
times = []
times.append(time.time())

tags = shared.tag.browseTags(path='Winery/Cask Hall', recursive=True)
tags = [str(tag['fullPath']) for tag in tags if str(tag['tagType']) == 'AtomicTag']
times.append(time.time())

alarmTagPaths=[]
alarmNames=[]
for tag in tags:
	config = system.tag.getConfiguration(basePath=tag)
	if 'alarms' in config:
		alarmTagPaths.append(tag)
		alarmNames.append(config['alarms'][0].get('name', 'Alarm')) # not sure if this would ever not exist



times.append(time.time())
print times[-1]-times[0], 's for ', len(tags), ' tags'

print 'Times'
for i in range(1,len(times)):
	print '\t', i, times[i]-times[i-1], 's'
4 Likes