# Getting the Initial Value that Triggered an Alarm

**URL:** <https://forum.inductiveautomation.com/t/getting-the-initial-value-that-triggered-an-alarm/53820>\
**Category:** Ignition\
**Created:** [December 6, 2021, 10:43pm UTC](https://forum.inductiveautomation.com/t/getting-the-initial-value-that-triggered-an-alarm/53820 "2021-12-06T22:43:21Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![awaege1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/awaege1/32/28922_2.png) [@awaege1](https://forum.inductiveautomation.com/u/awaege1)\
**Post date:** [December 6, 2021, 10:43pm UTC](https://forum.inductiveautomation.com/t/getting-the-initial-value-that-triggered-an-alarm/53820/1 "2021-12-06T22:43:21Z")

</div>

I am currently developing a system in which management can respond to alarm events via sms through a Twilio server. The functionality that I am trying to acheive is that the alarm is triggered, sends a notification to the manager, the manager then has the option to respond to the notification. If the manager responds, an acknowledge pipeline is triggered. The acknowledge pipeline then contains logic that saves the value that triggered the alarm as well as other associated data to a custom database table.

Now this works fine until I run into the situation where the tag that triggered the alarm clears it’s alarm state. Inside the acknowledge pipeline I am using the `event['eventValue']` property to get the value of the tag that triggered the alarm. The Ignition manual seemed to indicate that this property was the value that triggered the alarm, but it keeps returning the current value. I am assuming that this is just a misunderstanding of the documentation on my end. However, is there a way to get the value that triggered the alarm in the acknowledge pipeline, even after the alarm event has been cleared?

---

<div class="post-metadata">

**Author:** ![awaege1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/awaege1/32/28922_2.png) [@awaege1](https://forum.inductiveautomation.com/u/awaege1)\
**Post date:** [December 7, 2021, 5:00pm UTC](https://forum.inductiveautomation.com/t/getting-the-initial-value-that-triggered-an-alarm/53820/2 "2021-12-07T17:00:24Z")

</div>

Update:

After a good amount of investigation, it does not appear that there is currently a documented way to obtain the initial “active” alarm value from an acknowledge pipeline. This definitely seems like it should be possible since when looking at the alarm status table, the active event value is still retained in the alarm information even after the alarm is cleared and acknowledged.

I was able to create a workaround for this though. It appears that there is an undocumented dictionary value on the alarm pipeline for the database alarm UUID:

```auto
event['eventId']

```

Using this I was able to generate a query that allowed me to retrieve the active value from my acknowledge pipeline as follows:

```auto
SELECT aed.intvalue 
FROM alarm_event_data aed
JOIN alarm_events ae ON ae.id = aed.id
WHERE ae.eventtype = 0
AND aed.propname = 'eventValue'
AND ae.eventid =?

```

As I mentioned before, it does seem like this data should be easier to get. If anyone from inductive knows anything about this that I have not been able to discover I would be very curious.

---

<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:** [December 7, 2021, 5:11pm UTC](https://forum.inductiveautomation.com/t/getting-the-initial-value-that-triggered-an-alarm/53820/3 "2021-12-07T17:11:30Z")

</div>

In a script block, try `event.getActiveData()`; that should give you an [`EventData`](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.12/com/inductiveautomation/ignition/common/alarming/EventData.html) property set you can examine.

---

<div class="post-metadata">

**Author:** ![awaege1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/awaege1/32/28922_2.png) [@awaege1](https://forum.inductiveautomation.com/u/awaege1)\
**Post date:** [December 7, 2021, 5:22pm UTC](https://forum.inductiveautomation.com/t/getting-the-initial-value-that-triggered-an-alarm/53820/4 "2021-12-07T17:22:37Z")

</div>

In the pipline script block? I’ve tried calling the alarm property functions on that object but always get an error? I just tried what you suggested and also got an error. It seems like that event object being passed in is not actually the same type of alarm event object that would be generated by something like system.alarm.queryStatus() which you then could run the additional alarm methods against unless I am missing something here?

---

<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:** [December 7, 2021, 5:27pm UTC](https://forum.inductiveautomation.com/t/getting-the-initial-value-that-triggered-an-alarm/53820/5 "2021-12-07T17:27:21Z")

</div>

It should be:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/c/0c4459eec776caba9effef8a023443136f6064cd.png)

You could also call `sourceEvent()`; the `PyAlarmEvent` should then give you the underlying AlarmEvent directly.

I'd recommend poking around at the event object via Phil Turmel's introspection script:

> [@Finding all available methods from a component](https://forum.inductiveautomation.com/t/finding-all-available-methods-from-a-component/9670/8):
>
> The introspection script has evolved over time, particularly to return a string result instead of just printing. I found that useful for introspection in gateway scope using runScript() in an expression tag. Or to set the .text property of a scrollable text edit field for convenience. This is what it looks like today: # Introspection for Jython/Java # # Copyright 2008-2016 Automation Professionals, LLC \<sales@automation-pros.com\> # # Redistribution and use in source and binary forms, with or…

---

<div class="post-metadata">

**Author:** ![awaege1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/awaege1/32/28922_2.png) [@awaege1](https://forum.inductiveautomation.com/u/awaege1)\
**Post date:** [December 7, 2021, 7:01pm UTC](https://forum.inductiveautomation.com/t/getting-the-initial-value-that-triggered-an-alarm/53820/6 "2021-12-07T19:01:33Z")

</div>

So I can get the active data by use of `activeEvent = event.sourceEvent.getActiveData()` but I cannot seem to then pull any of the associated property data out of the event object. The documenation states that I should be able to use `get(String propertyName)` on this object but when I use `activeEvent.get('eventValue')` I get an error stating:

```auto
1st arg can't be coerced to com.inductiveautomation.ignition.common.config.Property

```

If I run `activeEvent.getProperties()` however, I do receive back a list of property names of which “eventValue” is one of them. Do I somehow need to use an actual property “type” as an insert into the get function instead of the string name and if so how would I do that?

---

<div class="post-metadata">

**Author:** ![awaege1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/awaege1/32/28922_2.png) [@awaege1](https://forum.inductiveautomation.com/u/awaege1)\
**Post date:** [December 7, 2021, 9:18pm UTC](https://forum.inductiveautomation.com/t/getting-the-initial-value-that-triggered-an-alarm/53820/7 "2021-12-07T21:18:36Z")

</div>

So after looking through the java docs, I managed to get an implementation that works without going through the database.

```auto
from com.inductiveautomation.ignition.common.alarming.evaluation import EventProperty
from com.inductiveautomation.ignition.common.alarming.config import CommonAlarmProperties
prop = EventProperty.createStatic(CommonAlarmProperties.EventValue, False)

activeEvent = event.sourceEvent()
activeData = activeEvent.getActiveData()

activeEventValue = activeData.get(prop)

```

This did the trick. I do still wish there was a more direct way to access active alarm data from an acknowledge pipeline though.

---

<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:** [December 7, 2021, 9:19pm UTC](https://forum.inductiveautomation.com/t/getting-the-initial-value-that-triggered-an-alarm/53820/8 "2021-12-07T21:19:37Z")

</div>

I was on my lunch break and about to type out pretty much exactly what you have there, so good stuff. For posterity, I’ll post it anyways:

* * *

Basically, yes.

The `PyAlarmEvent` wrapper has some helper methods to allow you to retrieve properties by name alone. By going to the ‘sourceEvent’ object, you’re no longer able to use those helper methods.

There are a few options:

1. Go through the `properties` list and find the one with the name you’re after:

```python
def findProperty(propertyset, propertyname):
	for prop in propertyset.properties:
		if prop.name == propertyname:
			return prop

activeData = event.sourceEvent.getActiveData()

prop = findProperty(activeData, "PropertyName")
if prop != None:
	value = activeData.getOrDefault(prop)

```

1. Find a reference to the property you’re looking for in the SDK. Depending on your version of Ignition, this might be easier or harder, but you could start with, e.g.  
[`CommonAlarmProperties`](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.12/com/inductiveautomation/ignition/common/alarming/config/CommonAlarmProperties.html)

---

<div class="post-metadata">

**Author:** ![mudbay](https://avatars.discourse-cdn.com/v4/letter/m/a4c791/32.png) [@mudbay](https://forum.inductiveautomation.com/u/mudbay)\
**Post date:** [October 11, 2024, 5:07pm UTC](https://forum.inductiveautomation.com/t/getting-the-initial-value-that-triggered-an-alarm/53820/9 "2024-10-11T17:07:45Z")

</div>

On this thread. Is there a way to get the EventValue using the 'system.alarm.queryJournal' function. I tried the above on the PyAlarmEvent returned, but the value 'property' doesn't seem to exist. I am using this function in some scripts for display in a Report Table Component.

Thanks in advance for the help.
