# system.opc.readValue / Values is not reading

**URL:** <https://forum.inductiveautomation.com/t/system-opc-readvalue-values-is-not-reading/29125>\
**Category:** Ignition\
**Tags:** ignition80, scripting\
**Created:** [October 16, 2019, 2:04pm UTC](https://forum.inductiveautomation.com/t/system-opc-readvalue-values-is-not-reading/29125 "2019-10-16T14:04:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![c.bertulli](https://avatars.discourse-cdn.com/v4/letter/c/f19dbf/32.png) [@c.bertulli](https://forum.inductiveautomation.com/u/c.bertulli)\
**Post date:** [October 16, 2019, 2:04pm UTC](https://forum.inductiveautomation.com/t/system-opc-readvalue-values-is-not-reading/29125/1 "2019-10-16T14:04:12Z")

</div>

Hi All,

I’m using IGNITION 8.0.5 RC1  
I have a script in Gateway Event Scripts that has to collect some tags and insert them inside the DB.  
The script is the following:

```auto
if not initialChange:
	if newValue.getValue():
	
		Server = 'Ignition OPC UA Server'
		#opcPathTest = '[S1500]DB1002,STRING140.100' #Nome Test
		opcPathNCiclo = '[S1500]DB1005,DI8012.0' # Numero del ciclo 
		#Tag_N_Sample = '[S1500]DB1005,DI0.0' #campionamenti totali per il singolo ciclo ( per far un for mirato )
		TagPathsPressure = ['[S1500]DB1005,REAL%2.1f' % x for x in range(4,4008,4)]
		TagPathsTime = ['[S1500]DB1005,DI%2.1f' % x for x in range(4008,8012,4)]
		
		#NomeTest = system.opc.readValue(Server,opcPathTest).value
		NomeTest = system.tag.readBlocking(['[default]PLC/Esperimento/Name Test'])[0].value
		N_Ciclo = system.opc.readValue(Server,opcPathNCiclo).value
		#N_Sample = system.opc.readValue(Server,Tag_N_Sample).value
		N_Sample = system.tag.readBlocking(['[default]PLC/Campionamenti/Impulsi TOT'])[0].value
		PressureValues = [x.value for x in system.opc.readValues(Server,TagPathsPressure)]
		TimeValues = [x.value for x in system.opc.readValues(Server,TagPathsTime)]
		
		Query = system.db.runPrepQuery('SELECT [ID] FROM [Test_Impulso] WHERE [Name] = ?',[NomeTest])
		ID_Test = Query[0][0]
		
		for j in range(0,N_Sample):
			stmt = 'INSERT INTO [ImpulsoToKeep]([ID_Test],[N_Ciclo],[Time],[Pressure]) VALUES (?,?,?,?)'
			system.db.runPrepUpdate(stmt,[ID_Test,N_Ciclo,TimeValues[j],PressureValues[j]])
		
		# Bit di HandShake
		system.tag.writeBlocking(['[default]PLC/Esperimento/Reset Impulsi'],[False])
		system.opc.writeValue(Server,'[S1500]DB1006,X14.4',0)

```

If I run the script inside the Script Console everything is done perfectly.  
If it runs from the Gateway Event Script I received an error that says that it cannot insert NULL value inside the database, because this line `PressureValues = [x.value for x in system.opc.readValues(Server,TagPathsPressure)]` is returning an array of None value.

Any idea?

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [October 16, 2019, 3:07pm UTC](https://forum.inductiveautomation.com/t/system-opc-readvalue-values-is-not-reading/29125/2 "2019-10-16T15:07:21Z")

</div>

Put the tag provider on ALL of your tag paths.  
Tag Event Scripts need to know what provider to issue the read call to.  
[default] if using the default tag provider.

---

<div class="post-metadata">

**Author:** ![c.bertulli](https://avatars.discourse-cdn.com/v4/letter/c/f19dbf/32.png) [@c.bertulli](https://forum.inductiveautomation.com/u/c.bertulli)\
**Post date:** [October 16, 2019, 3:25pm UTC](https://forum.inductiveautomation.com/t/system-opc-readvalue-values-is-not-reading/29125/3 "2019-10-16T15:25:08Z")

</div>

Sorry, but I don’t quite understand…  
You are talking about Tag Event Script. but I have this script on Gateway Event Script, also the tag provider is specified on all the TAGs

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [October 16, 2019, 4:17pm UTC](https://forum.inductiveautomation.com/t/system-opc-readvalue-values-is-not-reading/29125/4 "2019-10-16T16:17:13Z")

</div>

your tag paths for opcPathNCiclo,TagPathsPressure, and TagPathsTime do not have the provider in them.

```auto
		Server = 'Ignition OPC UA Server'
		#opcPathTest = '[S1500]DB1002,STRING140.100' #Nome Test
		opcPathNCiclo = '[S1500]DB1005,DI8012.0' # Numero del ciclo 
		#Tag_N_Sample = '[S1500]DB1005,DI0.0' #campionamenti totali per il singolo ciclo ( per far un for mirato )
		TagPathsPressure = ['[S1500]DB1005,REAL%2.1f' % x for x in range(4,4008,4)]
		TagPathsTime = ['[S1500]DB1005,DI%2.1f' % x for x in range(4008,8012,4)]

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 16, 2019, 6:24pm UTC](https://forum.inductiveautomation.com/t/system-opc-readvalue-values-is-not-reading/29125/5 "2019-10-16T18:24:55Z")

</div>

There’s some confusion over terminology… try to avoid using the keyword ‘tag’ for OPC items, as they aren’t tags in Ignition. They may be pointing at what are called tags in the target device, but tags in Ignition are something else.

Anyways, for the `system.opc.readValues()` calls, you should not use that list comprehension to extract `.value` unless you can handle None when your quality is bad. Consider logging the list returned by `readValues()` so you can inspect the quality codes to troubleshoot further.

---

<div class="post-metadata">

**Author:** ![c.bertulli](https://avatars.discourse-cdn.com/v4/letter/c/f19dbf/32.png) [@c.bertulli](https://forum.inductiveautomation.com/u/c.bertulli)\
**Post date:** [October 17, 2019, 7:49am UTC](https://forum.inductiveautomation.com/t/system-opc-readvalue-values-is-not-reading/29125/6 "2019-10-17T07:49:47Z")

</div>

Sorry about the terminology @MMaynard, as @pturmel said the paths without Provider are OPC Items and not TAG.

About the issue, I’ll try what you suggest
