Showing most recent alarms in vision alarm status table

Hello everyone,

I am trying to show the most recent alarms during the past 8 hours in the Alarm status table. Tried to find a way to do this but could not find any answer. Currently, I am seeing all the alarms but I want to limit this information to only the past 8 hours of alarm data. Appreciate any information/reference you could share.

Thank you!

Here you go:

https://docs.inductiveautomation.com/display/DOC79/system.alarm.queryStatus

1 Like

Entirely within the Alarm Status Table, you could also use the filterAlarm extension function to hide alarms outside your time window.

I have some reservations about the idea of hiding alarms purely based on time, but presumably you’ve got other ways to identify or deal with long-running alarm conditions…

1 Like

Thank you for your response!
I have tried to use the link you provided but could not find a way to do this. How can I use [system.alarm.queryStatus] to filter for the last 8 hours alarm?

Could not find any example in the manual or within this forum. Would you please provide an example of how this can be done using filterAlarm component scripting? Or is it possible to filter based on the Active time column?

alarmEvent.get('ActiveTime') will give you the time of the column

1 Like

I have tried that but not sure how can I use this information to filter the last 8 hours alarm.
The information I get from " alarmEvent.get('ActiveTime')" is:

Tue Oct 12 11:09:58 EDT 2021

How can I filter just the time to 8 hours? I am not able to find any example so that I can build mine based on that.

filterAlarm is fired once per alarm event and is required to return a boolean (in Java’s pseudo-functional parlance, a predicate).

So your implementation of filterAlarm simply needs to check whether the alarm’s ActiveTime is outside of your window.
You can use system.date.now to retrieve the current time during script execution.
You can use system.date.addHours to subtract eight hours from a given date.
You can use alarmEvent.get("ActiveTime") to get the time of your event.
You can use system.date.isAfter to compare two different dates and return a boolean (true/false).

Between those functions, you should be able to do what you want.

1 Like

Thank you very much, Paul. Appreciate the information.