Reading Tag Historian Values

Hi all, I have set up a tag historian for a PLC tag named : IGNR_Dust_Collector_Pressure_Diff_kPa . I want to set up alarms based on the tag history value and not the PLC value. How can I access this historian value through a tag?

What do you mean, alarms on the history ? What do you want to happen ?

I believe you need script.
Create a Expression tag, with "runScript" value and your alarm.
Create the "queryTagHistory" Script in the script library.
Here is some link you may need.

I have set up historian for the above mentioned tag since i want to capture the value every 10 minutes and i want to config an alarm to that captured historian value.

That makes no sense.
I'm sorry but... When does the alarm go off ? What's the trigger ?

1 Like

If I'm interpreting this correctly, you don't want an alarm notification until an alarm condition has been active for 10 consecutive minutes, and I'm guessing that you don't have access to the PLC program where a simple 10 minute timer could trigger a bool that is read by an alarm tag?

1 Like

I have never understood how a company can expect a person to program a SCADA system with out providing some way to make modifications to the device. There are just some things that should be handled at the device level.

1 Like

The trigger is a memory tag named "Alert Limit" which can be set by the engineer. So when the PLC value goes above the alert limit it will trigger the alarm.

NO I don't have access to PLC programs, actually i want the user to be notified as soon as the alarm triggers , but the problem with the PLC value is it jumps above the alert limit several times in a minute which triggers the alarms also several times/min. The PLC value jumps above this alert limit because the machine designed to the PLC works of pulses, and when a pulse is provided this PLC value jumps of the alert limit sometimes, these values are not required, so i set up a historian for the tag to capture the PLC value every 10 minutes. If I am able to config an alarm to that historian value it wont trigger unnecessary alarms and only the necessary ones.

I see, so what we are really wanting to do is get a notification at the moment the alarm occurs, and then, automatically mute any subsequent alarm notifications for 10 minutes.

Yeah, I basically want to write the historian value to a tag and config an alarm to that tag.

I still think you can create an expression tag with alarm config, and run a script to get the history value.

I wrote the query_tag_history() like this :

def query_tag_history():
	    # Import the necessary system functions
	    import system
	    # Get the current timestamp
	    end_time =
	    # Calculate the start timestamp by subtracting minutes_back from end_time
	    start_time =, -10)
	    # Query the tag history for the specified tag path and time range
	    data_set = system.tag.queryTagHistory(paths=['[IGNITION_TAGS]WANG BLASTER/IGNR_Dust_Collector_Pressure_Diff_kPa'], startDate=start_time, endDate=end_time, returnSize=1, aggregationMode='Average', returnFormat='Wide')
	    # Return the result of the query
	    return data_set

Also I created an expression tag and the expression i wrote is :
but the an ErrorEval comes up when i run this expression. Can u have a look at the script and help me with any error.

Did you config the Gateway Scripting Project, I'm sorry for forgetting to tell you this.


This function returns a Dataset , what's your tag data type?
If you want a numberic value, there is some thing more to do:




The (0,0) is the date.

No. If what you want is to mute alarms for 10 minutes after one occurred, what you want is a clear delay of 600 seconds:

Don't involve the historian there. This is a simple setting for a simple requirement.

1 Like

Perhaps he really want a average value. Actually, I think he wants to filter the historical value.
If so, take a try to Active Delay, Bharat_Krishnan.

Yes, maybe. But he never exposed what he wants to do, only how he tried to do it, so it's hard to come up with a clear idea of what should be done.