# How to test whether a tag has alarms configured?

**URL:** <https://forum.inductiveautomation.com/t/how-to-test-whether-a-tag-has-alarms-configured/59744>\
**Category:** Ignition\
**Created:** [May 18, 2022, 6:55pm UTC](https://forum.inductiveautomation.com/t/how-to-test-whether-a-tag-has-alarms-configured/59744 "2022-05-18T18:55:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tyler.bennett](https://avatars.discourse-cdn.com/v4/letter/t/f04885/32.png) [@tyler.bennett](https://forum.inductiveautomation.com/u/tyler.bennett)\
**Post date:** [May 18, 2022, 6:55pm UTC](https://forum.inductiveautomation.com/t/how-to-test-whether-a-tag-has-alarms-configured/59744/1 "2022-05-18T18:55:50Z")

</div>

What is the best way to determine whether a tag has any alarms configured (active or not), given a tag path passed as a parameter? I’m trying to show (or hide) an alarm indicator graphic (embedded view) dependent on whether the tag has configured alarms (the tag path is passed as a text parameter to the embedded view).

I have tried using the script below as a transform on a custom property, supplying the tag path for the property binding and checking for existence of the “Alarms” property folder. This actually works but ends up spamming the log with “Error reading path” messages showing the modified path with a “.name” property appended. Note that I don’t ever request the “.name” property. I understand that “Alarms” is a folder containing other properties, not a property itself.

Custom Property Binding:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/2/725848c9cd0b2159137d0603d61d857d7aa20f3c.png)

Log Error:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/d/dd72e1b047012b147da9f6fbc7145abba58edf96.png)

Eventually I transitioned to using an indirect tag binding to an Alarm property for the tag that should only exist if alarms are configured, then performing a !isNull() transform on it. This works and doesn’t create log spam… but this feels hackish.

Revised Custom Property Binding:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/7/3795db5e40ed043fce7e13cbd8e47978e175f2d1.png)

I think there must be a better/simpler way that I am just overlooking.

---

<div class="post-metadata">

**Author:** ![djs](https://avatars.discourse-cdn.com/v4/letter/d/e47774/32.png) [@djs](https://forum.inductiveautomation.com/u/djs)\
**Post date:** [May 18, 2022, 7:17pm UTC](https://forum.inductiveautomation.com/t/how-to-test-whether-a-tag-has-alarms-configured/59744/2 "2022-05-18T19:17:58Z")

</div>

Not perfect, but less hacky:

```auto
def hasAlarms(path):
	return len(system.tag.browse(path + "/Alarms/")) > 0

```

---

<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:** [May 18, 2022, 8:09pm UTC](https://forum.inductiveautomation.com/t/how-to-test-whether-a-tag-has-alarms-configured/59744/3 "2022-05-18T20:09:56Z")

</div>

Test if a tag has alarms in an expression:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/8/788c0a64c895ab49c72c737f3c6563a672a068f3.png)

in a script:

```python
def has_alarms(tag_path):
	return system.tag.readBlocking(["{}.quality".format(tag_path)])[0].value is not None

has_alarms("[]Test/test_pipeline")

```

> `>>> True`

---

<div class="post-metadata">

**Author:** ![swolnisty](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@swolnisty](https://forum.inductiveautomation.com/u/swolnisty)\
**Post date:** [May 18, 2022, 11:08pm UTC](https://forum.inductiveautomation.com/t/how-to-test-whether-a-tag-has-alarms-configured/59744/4 "2022-05-18T23:08:21Z")

</div>

Another option, if you wanted to search for which tags have alarms configured within a given folder would be doing something like this:

```auto
alarmTagList = []
path = '[default]Some/Tag/Folder'
results = system.tag.browse(path).getResults()
for result in results:
	tag = dict(result)
	if 'alarm' in str(tag.get('attributes', '')):
		alarmTagList.append(tag['fullPath'])
return alarmTagList

```

Though it’s probably a bit overkill for just determining if a single tag has alarms or not.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [May 19, 2022, 2:27am UTC](https://forum.inductiveautomation.com/t/how-to-test-whether-a-tag-has-alarms-configured/59744/5 "2022-05-19T02:27:30Z")

</div>

Calling `system.tag.browse` is a _ **lot** _ more expensive than binding to a tag and checking if it’s null
