# Alarm cleared and acknowledged data

**URL:** <https://forum.inductiveautomation.com/t/alarm-cleared-and-acknowledged-data/11149>\
**Category:** Ignition\
**Created:** [January 31, 2016, 4:25am UTC](https://forum.inductiveautomation.com/t/alarm-cleared-and-acknowledged-data/11149 "2016-01-31T04:25:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [January 31, 2016, 4:25am UTC](https://forum.inductiveautomation.com/t/alarm-cleared-and-acknowledged-data/11149/1 "2016-01-31T04:25:29Z")

</div>

I want to list alarm events in a report table in 7.7

I’ve found the event data in the database but can’t seem to find where the cleared and acknowledged info is stored?

---

<div class="post-metadata">

**Author:** ![Chris\_Taylor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/chris_taylor/32/3315_2.png) [@Chris\_Taylor](https://forum.inductiveautomation.com/u/Chris_Taylor)\
**Post date:** [January 31, 2016, 6:55pm UTC](https://forum.inductiveautomation.com/t/alarm-cleared-and-acknowledged-data/11149/2 "2016-01-31T18:55:21Z")

</div>

For me, a frustrating omission is the inability to access the data in the predefined alarm tables.

If I were doing an alarm report in 7.7 I’d make a hidden table on the page and run a script somthing like this, tied to a Date Range component

[code]start = event.source.parent.getComponent(‘Date Range’).startDate  
end = event.source.parent.getComponent(‘Date Range’).endDate  
cleared = system.alarm.queryJournal(journalName=“Journal”, state=[“ClearUnacked”,“ClearAcked”], startDate = start, endDate = end)  
active = system.alarm.queryJournal(journalName=“Journal”, state=[“ActiveUnacked”, “ActiveAcked”], startDate = start, endDate = end)

#dataset to pass to the table  
dataset = []  
#dataset to check the UUID of each event  
checked = []  
#Check all active alarms  
for alarm in range(len(active)):

```
id = active[alarm].getId()
#If we have not checked an alarm with this ID...
if id not in checked:
    #...add the UUID to checked
    checked.append(id)
    #get the time the alarm went active and convert it to a string
    #also, I clean up whe is returned
    activeDate = str(active[alarm].getActiveData())[11:22]
    activeTime = str(active[alarm].getActiveData())[22:30]
  # ack = active[alarm].getValues()
	alarmName = active[alarm].getName()
	DP = active[alarm].getDisplayPath()
	Priority = active[alarm].getPriority()
	State = active[alarm].getState()
	

	
	#The loop that checks for cleared alarms
    for i in range (len(cleared)):
        
        #find the matching cleared event if one exists
        if cleared[i].getId() == id:
        	#format the cleared event time
            clearedTime = str(cleared[i].getClearedData())[22:30]
            clearedDate = str(cleared[i].getClearedData())[11:22]

```

#Attempt to add the UUID, active time, and cleared time to the dataset named “dataset”.  
try:  
dataset.append([DP,alarmName,activeTime,activeDate,clearedTime,clearedDate,Priority,State])  
#if the append fails because cleared time is NULL, then insert a NULL into that column of the dataset  
except NameError:  
dataset.append([DP,alarmName,activeTime,activeDate,None,None,Priority,State])  
else:  
pass

```
        #Reset clearedTime for the next iteration through the loop
        clearedTime = None

```

header = [“Name”,“Alarm”,“Active Time”,“Active Date”, “Cleared Time”,“Cleared Date”, “Priority”, “State”,]

dataset = system.dataset.toDataSet(header, dataset)

event.source.parent.getComponent(‘Table’).data = dataset[/code]

You will have to modify it a bit to get the info you need, if you want cleared alarms as well, but it gives you something like the Alarm Journal in a table

You can then make the table one of your data sources.

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [February 2, 2016, 9:16am UTC](https://forum.inductiveautomation.com/t/alarm-cleared-and-acknowledged-data/11149/3 "2016-02-02T09:16:06Z")

</div>

Thanks Chris, had a go at that, got past a few stumbling blocks but it’s reporting on the line:

id = active[alarm].getId()

“alarm not defined”

any tips?

---

<div class="post-metadata">

**Author:** ![Chris\_Taylor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/chris_taylor/32/3315_2.png) [@Chris\_Taylor](https://forum.inductiveautomation.com/u/Chris_Taylor)\
**Post date:** [February 2, 2016, 11:30am UTC](https://forum.inductiveautomation.com/t/alarm-cleared-and-acknowledged-data/11149/4 "2016-02-02T11:30:52Z")

</div>

alarm is defined in the line above

```auto
for alarm in range(len(active)):
```

spelling and case correct?

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [February 3, 2016, 1:45am UTC](https://forum.inductiveautomation.com/t/alarm-cleared-and-acknowledged-data/11149/5 "2016-02-03T01:45:07Z")

</div>

Hi Chris, strange, I 1st tried this on my laptop and got that error… I moved onto the desktop and copied the code and it worked 1st time… thanks again for your help
