Building list of disabled alarms

I would like to get a list of disabled alarms so I can see which alarms are disabled and reenable them selectively. I've tried using

system.alarm.queryStatus(any_properties=[("enabled", "!=", "TRUE")])

but it doesn't return anything. What would be the best way to go about finding disabled alarms?

The enabled property isn't a string. Use jython's True instead of "TRUE".

Using True still returns nothing, running the inverse condition, "FALSE" or False does return all the enabled alarms.

Hmmm.

Try:

system.alarm.queryStatus(any_properties=[("enabled", "=", False), ("enabled", "=", None)])

That didn't seem to work either. Running with just system.alarm.queryStatus() it only returned the enabled alarms.

Would using system.tag.query perhaps be an alternative route to try?

Likely. If you use the Tag Report Tool to generate a working search, you can save as a jython script for further optimization.

1 Like

I have had similar behavior in the past and sort of assumed at a certain point in the alarming module, that a tag with disabled alarms was ignored the same as a tag with no alarm.

If all the tags you are looking at happen to be in one not-too-big part of the tag tree, you can get the desired result with system.tag.getConfiguration like this:

from com.inductiveautomation.ignition.common.tags.config.types import TagObjectType

def has_disabled_alarms(tag_config):
	return any((alarm_config['enabled'] != True) for alarm_config in tag_config.get('alarms',[]))

def filter_tag_configs(tag_config, filter_test, path_to_tag=None):
	if path_to_tag is None:
		path_to_tag = str(tag_config.get('path',''))
	else:
		path_to_tag = path_to_tag + '/' + str(tag_config.get('path',''))
	tag_type = tag_config.get('tagType','')
	tag_paths = []
	if tag_type == TagObjectType.Folder:
		for subtag in tag_config.get('tags',[]):
			tag_paths.extend(filter_tag_configs(subtag, filter_test, path_to_tag))
	elif tag_type == TagObjectType.AtomicTag:
		if filter_test(tag_config):
			tag_paths.append(path_to_tag)
	return tag_paths

tag_config = system.tag.getConfiguration('[default]sandbox', True)[0]
paths_to_tags_with_disabled_alarms = filter_tag_configs(tag_config, has_disabled_alarms)