Trouble using tag value in tag event script

I have the following code as a tag event script on a temperature tag

	value = int(currentValue.value) 
	tagPath = "[~]_Sample_Device_/Writeable/WriteableBoolean1.value"
	lowerLimit = system.tag.read("[~]lowerLimit.value")
	upperLimit = system.tag.read("[~]upperLimit.value")
	
	if value > upperLimit: 
		system.tag.writeAsync([tagPath], [0]) 
	elif value < lowerLimit: 
		system.tag.writeAsync([tagPath], [1])

I’m trying to get the code to use two number entry boxes to set an upper/lower limit at which to switch on/off a heater.
The above code is not working but if I replace the limits in the code with numbers like this:

	value = int(currentValue.value) 
	tagPath = "[~]_Sample_Device_/Writeable/WriteableBoolean1.value"
	
	if value > 28: 
		system.tag.writeAsync([tagPath], [0]) 
	elif value < 23: 
		system.tag.writeAsync([tagPath], [1])

It works.

What am I doing wrong?

system.tag.read() return a QualityValue so you need to .value
and .value its not needed in the tagpath

	tagPath = "[~]_Sample_Device_/Writeable/WriteableBoolean1"
	lowerLimit = system.tag.read("[~]lowerLimit").value
	upperLimit = system.tag.read("[~]upperLimit").value
2 Likes

That worked, thanks.

1 Like

Happy to help^^