readBlocking returns None for some tags

Hello, I've noticed that the same script returns "None" for some tags, but works just fine for the vast majority of others. Both are OPC tags belong to the same Data Type. The tags are basically identical as far as I can tell. Please see the script and console outputs below. Thanks for your time and help in advance!

configs = system.tag.getConfiguration(path)

# Iterate through the configs
for config in configs:
	# If the tag has configured alarms, get them
	if config.get('alarms'):
		alarms = config.get('alarms')

		# Iterate through the objects in the list alarms
		for alarm in alarms:
			print(alarm)

			# Pull the alarm name
			alarmName = alarm.get('name')

			# Pull the full alarm path to dervie the label, priority, and enabled
			alarmPath = '{}/Alarms/{}'.format(path, alarmName)
			# Pull the alarm Label, Priority, Enabled

			alarmData = system.tag.readBlocking(['{}.Label'.format(alarmPath), '{}.Priority'.format(alarmPath), '{}.Enabled'.format(alarmPath)])
			alarmLabel = alarmData[0].value
			alarmPriority = alarmData[1].value
			alarmEnabled = alarmData[2].value

			# Append the alarm data to the alarmList
			# alarmList.append([tagPath, alarmName, alarmLabel, alarmPriority, alarmEnabled])
			print([path, alarmName, alarmLabel, alarmPriority, alarmEnabled])
path1 = '[ProductGW]gPOR-(v3-2)/Bnx_FSA/DRS/AHU1/SPLY_FAN_STRSTP'
path2 = '[ProductGW]gPOR-(v3-2)/Bnx_FSA/DRS/AHU1/SPLY_FAN_DPSW804_STS'
output1 >>> {u'setpointA': 1.0, u'label': {u'bindType': u'Expression', u'value': u"replace(replace(substring({PathToParentFolder}, indexof({PathToParentFolder}, ')/')+2), '/' , ' '), '_', ' ') + ' '+ {name}"}, u'priority': Diagnostic, u'enabled': {u'bindType': u'Tag', u'value': u'[.]_enableAlarms'}, u'name': u'AHU Start/Stop'}
['[ProductGW]gPOR-(v3-2)/Bnx_FSA/DRS/AHU1/SPLY_FAN_STRSTP', u'AHU Start/Stop', None, None, None]

output2 >>> {u'setpointA': 1.0, u'label': {u'bindType': u'Expression', u'value': u"replace(replace(substring({PathToParentFolder}, indexof({PathToParentFolder}, ')/')+2), '/' , ' '), '_', ' ') + ' '+ {name}"}, u'priority': Diagnostic, u'enabled': {u'bindType': u'Tag', u'value': u'[.]_enableAlarms'}, u'name': u'AHU Supply Fan Run Status'}
['[ProductGW]gPOR-(v3-2)/Bnx_FSA/DRS/AHU1/SPLY_FAN_DPSW804_STS', u'AHU Supply Fan Run Status', u'Bnx FSA DRS AHU1 AHU Supply Fan Run Status', Diagnostic, True]

Generally, you get a null if the OPC item has bad quality. If you don't care about the actual quality, just look for these Nones in the .value of each QualifiedValue. If you do care, inspect the .quality property of each QV. (See the docs for readBlocking().)

3 Likes

Thanks for the input. Both OPC tags have Error_Configuration but it works for most. I found out the problem is that I have a "/" in the alarm name. Therefore it uses that forward slash in the alarm name when it formulate the alarmPath. We'll make it so that we don't use "/" in our alarm names and use "_" or something else instead. Thanks again!