Counting number of shelved alarms in Perspective

Hi,

How do keep track of the number of shelved alarm? I know len(system.alarm.queryStatus(state=[“ActiveUnacked”])) can be used to count the number of alarms based on state, but I don’t know the argument for shelved alarms. I tried “ShelvedUnacked”, but that is not correct.

Thanks,
Ali

It is a different call for shelved alarms.
https://docs.inductiveautomation.com/display/DOC81/system.alarm.getShelvedPaths

1 Like

I forgot about that function and went about it a different (probably non-performant) way:

    all_alarms = system.alarm.queryStatus(includeShelved=True)
	non_shelved = system.alarm.queryStatus(includeShelved=False)
	shelved_count = len(all_alarms) - len(non_shelved)

The logic looks pretty straight forward, but the count is off. I triggered 2 alarms and shelved one, but when I ran the script, it showed 3 shelved alarms.

I didn’t follow the example in the documentation. Could you please help me with the syntax to get a count of shelved alarms only?

count_of_shelved_alarms = len(system.alarm.getShelvedPaths())
1 Like

This logic counts ALL alarms, not just active alarms, so it sounds like you have two other alarms which are not active or shelved…

This might be better:

    # modify all_states to suit your needs
    all_states = ["ClearUnacked", "ClearAcked", "ActiveUnacked", "ActiveAcked"]
    all_alarms = system.alarm.queryStatus(state=all_states, includeShelved=True)
	non_shelved = system.alarm.queryStatus(state=all_states, includeShelved=False)
	shelved_count = len(all_alarms) - len(non_shelved)
1 Like

count_of_shelved_alarms = len(system.alarm.getShelvedPaths())

Thank you. This worked out perfectly.

1 Like