Custom Alarm Acknowledge Button

I am trying to create a custom button that acknowledged all unacknowledged alarms in the system. Here is my snippit of code and it isn’t working. Seems like it should from all of the documentation. The table is just so I can see the data.

from com.inductiveautomation.ignition.common.alarming import EventData
now = EventData()

table = event.source.parent.getComponent("Table")

list = system.alarm.queryStatus(state=["ClearUnacked"])

list[1].acknowledge(now)
table.data = list.getDataset()


In working with Tech Support, here is what we came up with.

stringlist = []

list = system.alarm.queryStatus(state=["ActiveUnacked"])

for id in list:
	stringlist.append(str(id.getId()))
	
system.alarm.acknowledge(stringlist,'')
4 Likes

Thanks.:grinning::grinning::grinning::grinning::grinning::grinning:

Thank you for this! I was about to give up on Ignition due to it’s limited alarming functionality.

list is a Python type, using list as a variable name overrides Python’s list type and is bad practice. Things like isinstance(variable, list) will fail after reassigning list

id is a builtin function and likewise should not be reassigned

Anyway, this is how I’d do it:

stringList = [str(alarm.getId()) for alarm in system.alarm.queryStatus(state=["ActiveUnacked"])]
system.alarm.acknowledge(stringList)

Or if you insist on not using list comprehension this does the same thing:

stringList = []
for alarm in system.alarm.queryStatus(state=["ActiveUnacked"]):
	stringList.append(str(alarm.getId()))
system.alarm.acknowledge(stringList)

but for the love of FSM do not use ‘id’ or ‘list’ as variable names. When the editor highlights a variable name alarm bells should be going off in your head

2 Likes

older thread but is there a way to modify this StringList to only acknowledge alarms in an alarm table? Since alarms are global across all clients we filter them based on location in plant. Since filter is done at alarm table level would be nice to ask only those alarms.

You just change the state= part to “ActiveAcked”
This is all covered in the docs.

https://docs.inductiveautomation.com/display/DOC79/system.alarm.queryStatus

I don’t think that would work…that would acknowledge any active alarm in any client. I need to only ack alarms on the open client’s alarm table. The same app is used in multiple places, and depending on the ‘place’, the alarm table is already filtered to only show alarms applicable to that place. I need to also only acknowledge those alarms with an external button. In that the User Login is unique to each place, I created a client tag for the User Login value, and on the value change of this script, I update the Alarm Table DisplayPath filters. I can use the same conditional scripting to ack by DisplayPath, but thought maybe there was an easy way to just obtain the GetID’s from the table since it’s already doing the filtering.

Ahh ok, I was confused by your wording.
You can just do the Ack on the filtered alarm list.

src = "prov:default:/tag:Path/To/Filtered/Alarm/Folder/*"
results = system.alarm.queryStatus(state=['ActiveUnacked'],source=[src])
for item in results:
	eventID = "%s" % (item.getId())
	system.alarm.acknowledge([eventID], 'None')

Replace src with your Source Filter you are using on the alarm status table.

Yep, that’s what I’m doing, but not with Sources…using the Display Paths instead, but same principle. The way the plant set up the Paths previously, it’s a bit cumbersome to try and use sources. Thanks.