# isAlarmActive with polling rate

**URL:** <https://forum.inductiveautomation.com/t/isalarmactive-with-polling-rate/39348>\
**Category:** Ignition\
**Tags:** ignition80, perspective\
**Created:** [October 4, 2020, 3:13pm UTC](https://forum.inductiveautomation.com/t/isalarmactive-with-polling-rate/39348 "2020-10-04T15:13:48Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![kgamble](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kgamble/32/8019_2.png) [@kgamble](https://forum.inductiveautomation.com/u/kgamble)\
**Post date:** [October 4, 2020, 3:13pm UTC](https://forum.inductiveautomation.com/t/isalarmactive-with-polling-rate/39348/1 "2020-10-04T15:13:48Z")

</div>

I feel like maybe I am missing something here, but when I try to use the [isAlarmActive expression](https://docs.inductiveautomation.com/display/DOC80/isAlarmActive) with a polling rate as a binding in perspective, I cant give it a polling rate without it failing. Unfortunately the documentation only shows it with multiple tags, not with a polling rate.

Here is what I have:

```auto
isAlarmActive("[MyProvider]MyFolder/MyTagWithAnAlarm", "MyAlarmName", 5000)

```

Here is the error:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/c/2cd8e7c5eec2f9e24df52c4786ac5d7d3a276f42.png)

I can force it to poll by doing this, but Its kind of a cheeky workaround

```auto
if(now(5000) != "", isAlarmActive("[MyProvider]MyFolder/MyTagWithAnAlarm"), "")

```

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [October 5, 2020, 3:17pm UTC](https://forum.inductiveautomation.com/t/isalarmactive-with-polling-rate/39348/2 "2020-10-05T15:17:36Z")

</div>

From a glance at the code, I think there’s no ability to specify a poll rate on the gateway because it shouldn’t be necessary. On the gateway we should be able to directly hook into the tags with listeners, and get triggered value changes.

---

<div class="post-metadata">

**Author:** ![kgamble](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kgamble/32/8019_2.png) [@kgamble](https://forum.inductiveautomation.com/u/kgamble)\
**Post date:** [October 5, 2020, 5:12pm UTC](https://forum.inductiveautomation.com/t/isalarmactive-with-polling-rate/39348/3 "2020-10-05T17:12:18Z")

</div>

So then as a clarification, I am not seeing the binding auto-reevaluate when the alarm is triggered

However it does auto-reevaluate by binding directly to the alarm isActive tag path

---

<div class="post-metadata">

**Author:** ![jd1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jd1/32/18928_2.png) [@jd1](https://forum.inductiveautomation.com/u/jd1)\
**Post date:** [August 27, 2021, 10:04pm UTC](https://forum.inductiveautomation.com/t/isalarmactive-with-polling-rate/39348/4 "2021-08-27T22:04:41Z")

</div>

so is this part of the user manual a typo then?

**isAlarmActive(tagPath, [alarmName], [pollRate])**

- Parameters

String tagPath - The Tag path to search for active alarms. Supports the wildcard ‘\*’.

String alarmName - The name of the alarm to search for. Supports the wildcard ‘\*’. [optional]

Integer pollRate - The poll rate in milliseconds. Only applicable in the Client scope. [optional]

- Returns

Boolean - True if an alarm is active; False if no active alarms were found.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 27, 2021, 10:06pm UTC](https://forum.inductiveautomation.com/t/isalarmactive-with-polling-rate/39348/5 "2021-08-27T22:06:01Z")

</div>

Which part?

---

<div class="post-metadata">

**Author:** ![jd1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jd1/32/18928_2.png) [@jd1](https://forum.inductiveautomation.com/u/jd1)\
**Post date:** [August 27, 2021, 10:07pm UTC](https://forum.inductiveautomation.com/t/isalarmactive-with-polling-rate/39348/6 "2021-08-27T22:07:05Z")

</div>

> [@kgamble](#):
>
> `if(now(5000) != "", isAlarmActive("[MyProvider]MyFolder/MyTagWithAnAlarm"), "")`

The part about being able to set a poll rate?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 27, 2021, 10:08pm UTC](https://forum.inductiveautomation.com/t/isalarmactive-with-polling-rate/39348/7 "2021-08-27T22:08:19Z")

</div>

The user manual already states it’s only applicable in Client scope.

Perspective is not “Client” scope. We’ve been making an effort to say “Vision Client” where applicable in the user manual to try to make that more clear, looks like we missed a spot.

---

<div class="post-metadata">

**Author:** ![jd1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jd1/32/18928_2.png) [@jd1](https://forum.inductiveautomation.com/u/jd1)\
**Post date:** [August 27, 2021, 10:11pm UTC](https://forum.inductiveautomation.com/t/isalarmactive-with-polling-rate/39348/8 "2021-08-27T22:11:32Z")

</div>

ah ok, that makes sense. I didn’t realize the distinction. Is there anyway to add that to perspective? My binding seems to respond when an alarm goes from in-active to active, but when the alarm clears it doesn’t change.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 27, 2021, 10:12pm UTC](https://forum.inductiveautomation.com/t/isalarmactive-with-polling-rate/39348/9 "2021-08-27T22:12:59Z")

</div>

I think Paul’s original point here is that polling isn’t necessary in the gateway. If the binding isn’t behaving properly then it might be a bug.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 27, 2021, 10:15pm UTC](https://forum.inductiveautomation.com/t/isalarmactive-with-polling-rate/39348/10 "2021-08-27T22:15:26Z")

</div>

Is your execution mode currently set to Event Driven?

edit: assuming this is on an Expression Tag

---

<div class="post-metadata">

**Author:** ![jd1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jd1/32/18928_2.png) [@jd1](https://forum.inductiveautomation.com/u/jd1)\
**Post date:** [August 27, 2021, 10:18pm UTC](https://forum.inductiveautomation.com/t/isalarmactive-with-polling-rate/39348/11 "2021-08-27T22:18:00Z")

</div>

I’m using it on a property binding to set a style class when an alarm is active

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 27, 2021, 10:19pm UTC](https://forum.inductiveautomation.com/t/isalarmactive-with-polling-rate/39348/12 "2021-08-27T22:19:55Z")

</div>

I think we already have an issue for this… I’m going to update it and put it in the backlog, hopefully for next sprint.

---

<div class="post-metadata">

**Author:** ![zachariah.batson](https://avatars.discourse-cdn.com/v4/letter/z/7feea3/32.png) [@zachariah.batson](https://forum.inductiveautomation.com/u/zachariah.batson)\
**Post date:** [September 2, 2021, 7:26pm UTC](https://forum.inductiveautomation.com/t/isalarmactive-with-polling-rate/39348/13 "2021-09-02T19:26:00Z")

</div>

JD, I’m having the same issue. The function works as long as I click apply in the ‘Edit Binding’ window after an alarm state change so there seems to be no automatic polling.

---

<div class="post-metadata">

**Author:** ![ken.maze](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ken.maze/32/85876_2.png) [@ken.maze](https://forum.inductiveautomation.com/u/ken.maze)\
**Post date:** [September 9, 2021, 10:06pm UTC](https://forum.inductiveautomation.com/t/isalarmactive-with-polling-rate/39348/14 "2021-09-09T22:06:48Z")

</div>

I’m having the same problem. I want to highlight certain urgent alarms by making a slow-flashing style class on the root of the view. One of them is if our main database goes unavailable. It works fine if I bind directly to the tag, but I have a 30 second active delay on it. The transition doesn’t get caught.

Thanks

---

<div class="post-metadata">

**Author:** ![ken.maze](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ken.maze/32/85876_2.png) [@ken.maze](https://forum.inductiveautomation.com/u/ken.maze)\
**Post date:** [May 1, 2023, 7:49pm UTC](https://forum.inductiveautomation.com/t/isalarmactive-with-polling-rate/39348/15 "2023-05-01T19:49:31Z")

</div>

I'm back. Is there any progress on this? Example, I have two tags, [default]Temp/Alarm Test and  
[default]Temp/Alarm Test 3

I am using  
` isAlarmActive("[default]Temp/Alarm*")`

bound to a label. That label doesn't change live. However, if I bind either one of the alarms to the label  
`isAlarmActive("[default]Temp/Alarm Test")`  
, those labels will change. Also, I can do:

```auto
isAlarmActive("[default]Temp/Alarm Test") ||
isAlarmActive("[default]Temp/Alarm Test 3")

```

And that will change live, which is fine here, but I will soon be implementing 30+ tags into a folder that I want to check to see if any of them go active, and I don't want to have to type them all out and maintain the list if a tag changes.

Thanks

---

<div class="post-metadata">

**Author:** ![Ryan\_Allen](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan_allen/32/47013_2.png) [@Ryan\_Allen](https://forum.inductiveautomation.com/u/Ryan_Allen)\
**Post date:** [May 1, 2023, 8:03pm UTC](https://forum.inductiveautomation.com/t/isalarmactive-with-polling-rate/39348/16 "2023-05-01T20:03:22Z")

</div>

This is how I do it:

New script in Scripting -\> Project Library -\> "templates" (or whatever you want to call it) with the following code:

```auto
def getActiveChildrenAlarms(tagPath):
	
	# Check if tag path is not empty
	if tagPath!='':
		# Split the tag path to get the tag name
		splitPath = tagPath.split(']')
		# Create a filter to get all alarms that have the tag name in their path
		filter = ['*%s*' % splitPath[-1]]
		# Get all active alarms for the filter
		states = ['ActiveUnacked','ActiveAcked']
		activeAlarms = system.alarm.queryStatus(Path = filter,state = states)
		# Create a list of alarms and their states
		ret = []
		for alarm in activeAlarms:
			item = {
				'name': str(alarm.getName()),
				'state': str(alarm.getState())
			}
			ret.append(item)
	else:
		# Return an empty list if tag path is empty
		ret = []
	
	return ret

```

Create a view prop called "rootTagPath" which holds the tag path, i.e. [default]SBR/Basin1/Basin1Mixer

Then I have a custom prop object called motorAlarms with an expression + script transform binding:

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

This lets you bind something such as a style class like so:

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

Can't promise this is the most efficient method, but it works. I'm sure @pturmel will tell me I'm doing something stupid.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 1, 2023, 8:13pm UTC](https://forum.inductiveautomation.com/t/isalarmactive-with-polling-rate/39348/17 "2023-05-01T20:13:35Z")

</div>

> [@Ryan\_Allen](#):
>
> `system.alarm.queryStatus`

This is an absurdly expensive system call, especially with wildcards. Don't call it from a UI. Call it from a timer event, with parameters that will satisfy all users. Divvy up the results into project script top-level dictionaries (or dataset or document tags, perhaps) that UI consumers can hit with near-zero latency.

---

<div class="post-metadata">

**Author:** ![Ryan\_Allen](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan_allen/32/47013_2.png) [@Ryan\_Allen](https://forum.inductiveautomation.com/u/Ryan_Allen)\
**Post date:** [May 1, 2023, 8:19pm UTC](https://forum.inductiveautomation.com/t/isalarmactive-with-polling-rate/39348/18 "2023-05-01T20:19:43Z")

</div>

Haha. I figured there would be something

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 1, 2023, 8:22pm UTC](https://forum.inductiveautomation.com/t/isalarmactive-with-polling-rate/39348/19 "2023-05-01T20:22:33Z")

</div>

That particular function, called in a Vision runScript binding, will bring a high-latency (VPN, WAN) client to screeching halt. Perspective is a bit more tolerant, but still not a good idea.

---

<div class="post-metadata">

**Author:** ![ken.maze](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ken.maze/32/85876_2.png) [@ken.maze](https://forum.inductiveautomation.com/u/ken.maze)\
**Post date:** [May 1, 2023, 8:23pm UTC](https://forum.inductiveautomation.com/t/isalarmactive-with-polling-rate/39348/20 "2023-05-01T20:23:25Z")

</div>

Here is what I have done. I made a tag that calls isAlarmActive, Made it Fixed Rate Execution mode and set the poll rate to 1,000. Seems to work. I don't know if the poll rate is too fast? I would like for it to react relatively quickly, but don't want to suck down all the resources doing it.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/f/afbe5789ca7e277154771dcb8e2e8d3ab2e3e541.png)

[Next page](https://forum.inductiveautomation.com/t/isalarmactive-with-polling-rate/39348.md?page=2)
