# API Call on alarm trigger

**URL:** <https://forum.inductiveautomation.com/t/api-call-on-alarm-trigger/77993>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [August 17, 2023, 12:51pm UTC](https://forum.inductiveautomation.com/t/api-call-on-alarm-trigger/77993 "2023-08-17T12:51:52Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Hayden\_Watson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/hayden_watson/32/48792_2.png) [@Hayden\_Watson](https://forum.inductiveautomation.com/u/Hayden_Watson)\
**Post date:** [August 18, 2023, 7:38am UTC](https://forum.inductiveautomation.com/t/api-call-on-alarm-trigger/77993/3 "2023-08-18T07:38:51Z")

</div>

I've had a go at getting it working based on the thread:

> [@How to trigger a gateway timer to trigger immediately but no more than four times per minute?](https://forum.inductiveautomation.com/t/how-to-trigger-a-gateway-timer-to-trigger-immediately-but-no-more-than-four-times-per-minute/75476):
>
> I have a gateway timer script that is configured to run every 15 seconds. ds = system.tag.read("[default]Queue").value if ds.getRowCount() \> 0: # Get value from queue message = ds.getValueAt(0, "message") # Complete some arbitrary stuff specialFunctions.myFunction(message) # Delete value from dataset new\_ds = system.dataset.deleteRow(ds, 0) # Write new dataset back to queue system.tag.write("[default]Queue", new\_ds) I have up to 100 tags feeding a queue. The purpose of the gateway t…

I had some issues where my .offer didn't seem to actually append anything to my queue.

I made a project library script called alarmQueue:

```auto
from java.util.concurrent import LinkedBlockingDeque, TimeUnit
logger = system.util.getLogger("Alarm Event Queue")
# Capacity = 100. The new instance is thrown away if already in globals.

deque = system.util.getGlobals().setdefault('MyAlarmQueue', LinkedBlockingDeque(100))

def someTimerEvent():
	nextItem = deque.poll(15000, TimeUnit.MILLISECONDS)
	#logger.info(str(system.util.getGlobals()))
	if nextItem:
		pass
		
# Run the above at a fixed **rate** matching the poll timeout.

def addDeque(message):
	response = deque.offer(str(message))
	logger.warn(str(response))

```

I call the someTimerEvent() every 15000 ms in a timer script (using dedicated thread, fixed rate), I added the addDeque to the alarm active script on a a testing tag, with the below script:

```auto
	path = str(alarmEvent.getDisplayPath())
	
	AlarmQueue.addDeque(path)

```

The response value always returns a `True`, but whenever I try querying the queue using:  
`print AlarmQueue.Deque` is just returns single value even though I trigger my alarm several times. They also dissapear after some time, does this timer event erase the queue?

Where am I getting it wrong? Or is it okay, I just don't know how to get the data back out of it

---

_[View the full topic](https://forum.inductiveautomation.com/t/api-call-on-alarm-trigger/77993)._
