# If Alarm Exists

**URL:** <https://forum.inductiveautomation.com/t/if-alarm-exists/56977>\
**Category:** Ignition\
**Tags:** ignition81, scripting\
**Created:** [March 8, 2022, 7:34pm UTC](https://forum.inductiveautomation.com/t/if-alarm-exists/56977 "2022-03-08T19:34:18Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [March 8, 2022, 7:34pm UTC](https://forum.inductiveautomation.com/t/if-alarm-exists/56977/1 "2022-03-08T19:34:18Z")

</div>

I can use this function to determine if a tag exists,  
[https://docs.inductiveautomation.com/display/DOC81/system.tag.exists](https://docs.inductiveautomation.com/display/DOC81/system.tag.exists)

Is there anything quick and easy to see if an alarm exists within a specified tag?

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [March 8, 2022, 8:45pm UTC](https://forum.inductiveautomation.com/t/if-alarm-exists/56977/2 "2022-03-08T20:45:41Z")

</div>

You can use [/system.tag.getConfiguration](https://docs.inductiveautomation.com/display/DOC81/system.tag.getConfiguration) which will return a list of tag dictionaries. Then you just need to check for “alarms”

Something like this:

```auto
path = '[default]New Tag'
config = system.tag.getConfiguration(path, False)

try:
	config[0]['alarms']
except:
	print 'no alarms'

```

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [March 8, 2022, 10:59pm UTC](https://forum.inductiveautomation.com/t/if-alarm-exists/56977/3 "2022-03-08T22:59:43Z")

</div>

Thanks @josborn I was aware I could do that, was curious if there was another way. Appreciate the response.

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [March 8, 2022, 11:01pm UTC](https://forum.inductiveautomation.com/t/if-alarm-exists/56977/4 "2022-03-08T23:01:25Z")

</div>

No prob! I suppose you could export all your tax as xml or json and then iterate through and return the ones that have alarms.

---

<div class="post-metadata">

**Author:** ![stat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/stat/32/32530_2.png) [@stat](https://forum.inductiveautomation.com/u/stat)\
**Post date:** [March 9, 2022, 12:28am UTC](https://forum.inductiveautomation.com/t/if-alarm-exists/56977/5 "2022-03-09T00:28:48Z")

</div>

@jlandwerlen You can use system.tag.exists with the path to the alarms property from the tag and that path would be [tag\_provider]tagpath/Alarms/Alarm\_Name.

For example with a memory tag called "Test" and an alarm named "Test Alarm", the following returns True.  
`system.tag.exists("[default]Test/Alarms/Test Alarm")`

@josborn Keep in mind that the system.tag.getConfiguration method will work well for individual tags like a single memory or OPC tag; however, if you use your method on a tag in a UDT instance, you would print "no alarms" even if the tag has alarms. The reason the UDT instance does not include the "alarms" property in its config is because it is inherited from the UDT definition. If you were to make an edit on the alarm on the UDT tags, then you will see the "alarms" property returned by getConfiguration because you will have created an override on the alarm property making it different from the UDT definition.

In the manual section for system.tag.getConfiguration, we mention this here:

> The configurations returned by this function can only contain properties that are **not** using their default values. Thus, if a property on a tag has not been modified from its default value, then it will be included in the returned list.

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [March 9, 2022, 12:35am UTC](https://forum.inductiveautomation.com/t/if-alarm-exists/56977/6 "2022-03-09T00:35:05Z")

</div>

Good point, and that’s exactly what i did, test on a single memory tag. Your answer is much better, i didn’t know you could use `system.tag.exists()` that way.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [March 9, 2022, 9:07am UTC](https://forum.inductiveautomation.com/t/if-alarm-exists/56977/7 "2022-03-09T09:07:25Z")

</div>

> [@stat](#):
>
> For example with a memory tag called “Test” and an alarm named “Test\_Alarm”, the following returns True.  
> `system.tag.exists("[default]Test/Alarms/Test Alarm")`

Why the difference between the alarm name and the tag path ? I mean, the underscore in the alarm name is replaced by a space in the tag path. Is this a typo, or is there some black magic at work there ?

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [March 9, 2022, 11:46am UTC](https://forum.inductiveautomation.com/t/if-alarm-exists/56977/8 "2022-03-09T11:46:41Z")

</div>

> [@stat](#):
>
> @jlandwerlen You can use system.tag.exists with the path to the alarms property from the tag and that path would be [tag\_provider]tagpath/Alarms/Alarm\_Name.

Thanks, I didn't even think to try that. Great to know.

---

<div class="post-metadata">

**Author:** ![stat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/stat/32/32530_2.png) [@stat](https://forum.inductiveautomation.com/u/stat)\
**Post date:** [March 9, 2022, 4:16pm UTC](https://forum.inductiveautomation.com/t/if-alarm-exists/56977/9 "2022-03-09T16:16:03Z")

</div>

@pascal.fragnoud No dark sorcery here. Just a person and his typos. 🙂 You’re correct. The alarm names should match.
