# Counting number of shelved alarms in Perspective

**URL:** <https://forum.inductiveautomation.com/t/counting-number-of-shelved-alarms-in-perspective/44814>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [March 23, 2021, 7:04pm UTC](https://forum.inductiveautomation.com/t/counting-number-of-shelved-alarms-in-perspective/44814 "2021-03-23T19:04:40Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ali.Etezadkhah](https://avatars.discourse-cdn.com/v4/letter/a/b19c9b/32.png) [@Ali.Etezadkhah](https://forum.inductiveautomation.com/u/Ali.Etezadkhah)\
**Post date:** [March 23, 2021, 7:04pm UTC](https://forum.inductiveautomation.com/t/counting-number-of-shelved-alarms-in-perspective/44814/1 "2021-03-23T19:04:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [March 23, 2021, 7:37pm UTC](https://forum.inductiveautomation.com/t/counting-number-of-shelved-alarms-in-perspective/44814/2 "2021-03-23T19:37:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [March 23, 2021, 7:45pm UTC](https://forum.inductiveautomation.com/t/counting-number-of-shelved-alarms-in-perspective/44814/3 "2021-03-23T19:45:17Z")

</div>

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

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

```

---

<div class="post-metadata">

**Author:** ![Ali.Etezadkhah](https://avatars.discourse-cdn.com/v4/letter/a/b19c9b/32.png) [@Ali.Etezadkhah](https://forum.inductiveautomation.com/u/Ali.Etezadkhah)\
**Post date:** [March 24, 2021, 4:54pm UTC](https://forum.inductiveautomation.com/t/counting-number-of-shelved-alarms-in-perspective/44814/4 "2021-03-24T16:54:35Z")

</div>

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.

 ![shelved](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/0/902293731275a03a8bc3682747f29d1e63c39004.jpeg)

---

<div class="post-metadata">

**Author:** ![Ali.Etezadkhah](https://avatars.discourse-cdn.com/v4/letter/a/b19c9b/32.png) [@Ali.Etezadkhah](https://forum.inductiveautomation.com/u/Ali.Etezadkhah)\
**Post date:** [March 24, 2021, 4:56pm UTC](https://forum.inductiveautomation.com/t/counting-number-of-shelved-alarms-in-perspective/44814/5 "2021-03-24T16:56:21Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [March 24, 2021, 5:02pm UTC](https://forum.inductiveautomation.com/t/counting-number-of-shelved-alarms-in-perspective/44814/6 "2021-03-24T17:02:43Z")

</div>

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

```

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [March 24, 2021, 5:07pm UTC](https://forum.inductiveautomation.com/t/counting-number-of-shelved-alarms-in-perspective/44814/7 "2021-03-24T17:07:27Z")

</div>

> [@Ali.Etezadkhah](#):
>
> 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.

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:

```auto
    # 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)

```

---

<div class="post-metadata">

**Author:** ![Ali.Etezadkhah](https://avatars.discourse-cdn.com/v4/letter/a/b19c9b/32.png) [@Ali.Etezadkhah](https://forum.inductiveautomation.com/u/Ali.Etezadkhah)\
**Post date:** [April 5, 2021, 5:23pm UTC](https://forum.inductiveautomation.com/t/counting-number-of-shelved-alarms-in-perspective/44814/9 "2021-04-05T17:23:04Z")

</div>

count\_of\_shelved\_alarms = len(system.alarm.getShelvedPaths())

Thank you. This worked out perfectly.
