Would like to add a Tag Name Alias

Just wondering if this sounds reasonable.

I currently have script that creates a Tag Path, History and POST dataset. I'm wondering where would be the best place (if any) to replace the tag name before the POST is sent out with an alias tag name.

The Tag Path has the paths to tags that need to be POSTed.

The History dataset is created with Tag Path dataset and the system.tag.queryTagHistory function.

Then the POST dataset is created by breaking up each row of the History dataset in to JSON format with each of the key values needed. Currently it splits the tag name out of each row in the History dataset.

I can add a custom property Alias Name in each tag and read it with the system.tag.readBlocking function. I was wondering if I could create a forth dataset with all the Alias Name custom property values. Then I could reference it for the tag name when creating the POST dataset instead of referencing the History dataset.

I fear that reading all the Alias Name properties from each tag could cause overhead issues when POSTs are sent out.

Another issue is setting up the Alias Name. I have a script to create UDT instances from a CSV file with the system.tag.configure function but if I need to change the Alias Name custom property, it seems like it would be best to just make that change in the parent UDT as long as they are the same in each UDT instance.

Can you post your script so we can see what it is currently doing?

It's a bit of mess and I (mostly) know not, what I do. :slight_smile:

For testing, I changed the line getting the 'point' key value and it is working, but getting the alias here means it's checking for every value found for every tag, and the POST is happening every few minutes.

The idea was to make an AliasName list from the Tag Path list, but it would not have the same number of items/rows as the History list used to create the newPOST list.

I can't just replace the point key value line
history.getValueAt(rowIndex, 0).split('/')[-1]
with
AliasName.getValueAt(rowIndex, 0).

I can try it like it is, checking every item in the History list or maybe see if I can make a script function to check each path in the Tag Path list. If it has a tag name alias, search for that same path in the History list and replace all the instances of it with the alias tag name. Not sure how much that would help efficiency.

Check all tags in the Tag Path list, even if a tag has no historical data, and then try to search and replace all those in the History list, lets say 1000 tags or check all the tags that had historical data and made it into the History list, lets say 100 tags with 10 samples for each.

	for rowIndex in range(history.getRowCount()):
			path_parts = history.getValueAt(rowIndex, 0).split('/')
			newPOST.extend(
				[
					{
						'system': findEquals(System_subSystem_Dataset, "[default]" + history.getValueAt(rowIndex, 0), 'System_ID'),
						'subSystem': findEquals(System_subSystem_Dataset, "[default]" + history.getValueAt(rowIndex, 0), 'subSystem_ID'),
						'equipment': path_parts[-2],
						#'point': history.getValueAt(rowIndex, 0).split('/')[-1],  						# Get the tag name after the last '/'
						'point': system.tag.readBlocking(["[default]" + str(history.getValueAt(rowIndex, 0)) + ".Alias Name"])[0].value,
						'timestamp': str(system.date.fromMillis(history.getValueAt(rowIndex, 3).getTime()).toInstant()),							# Convert timestamp to UCT
						'value': history.getValueAt(rowIndex, 1)
					}
				]
			)