valueChanged error

Trying to create a valueChanged script with a numeric entry field. Any guidance would be greatly appreciated.

code:
‘’’
import string
x = previousValue.value
y = currentValue.value
if self.view.custom.PM.ewonType == 1:
if x != y:
server = “AWS Mosquitto”
topic = self.session.custom.Location[0].countryName+"/"+self.session.custom.Location[0].stateName+"/"+str(self.view.custom.PM.depotID)+"/"+self.view.params.id+"/Screw Speed"

		param = str(self.props.value)
		payload = param.encode()
		
		system.cirruslink.engine.publish(server, topic, payload, 0,0)

‘’
i am receiving the below error:

com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last): File “”, line 3, in valueChanged AttributeError: ‘NoneType’ object has no attribute ‘value’

at org.python.core.Py.AttributeError(Py.java:207)

at org.python.core.PyObject.noAttributeError(PyObject.java:1032)

at org.python.core.PyObject.getattr(PyObject.java:1027)

at org.python.pycode._pyx5770.valueChanged$1(:15)

at org.python.pycode._pyx5770.call_function()

at org.python.core.PyTableCode.call(PyTableCode.java:171)

at org.python.core.PyBaseCode.call(PyBaseCode.java:308)

at org.python.core.PyFunction.function___call__(PyFunction.java:471)

at org.python.core.PyFunction.call(PyFunction.java:466)

at org.python.core.PyFunction.call(PyFunction.java:456)

at org.python.core.PyFunction.call(PyFunction.java:451)

at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:776)

at com.inductiveautomation.ignition.common.script.ScriptManager$ScriptFunctionImpl.invoke(ScriptManager.java:894)

at com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$AutoRecompilingScriptFunction.invoke(ProjectScriptLifecycle.java:574)

at com.inductiveautomation.perspective.gateway.script.ScriptFunctionHelper.invoke(ScriptFunctionHelper.java:87)

at com.inductiveautomation.perspective.gateway.model.PropertyChangeScript.onValueChanged(PropertyChangeScript.java:102)

at com.inductiveautomation.perspective.gateway.property.PropertyTree$Notifier.run(PropertyTree.java:175)

at com.inductiveautomation.ignition.common.util.ExecutionQueue$PollAndExecute.run(ExecutionQueue.java:232)

at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)

at java.base/java.util.concurrent.FutureTask.run(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.base/java.lang.Thread.run(Unknown Source)

Caused by: org.python.core.PyException: Traceback (most recent call last): File “”, line 3, in valueChanged AttributeError: ‘NoneType’ object has no attribute ‘value’

This is the line the error is flagging, and the error is basically saying currentValue isn't defined (or has a null value)

x = previousValue.value

is actually the true failure line due to line “1” of the script consisting of the script def line.
45%20AM
Your Numeric Entry Field component has no value to start, even though the component itself displays 0.
51%20AM
If you supply an initial value for the Numeric Entry Field, then the script evaluation error will no longer appear.

2 Likes