This error only appears when I am using a UDT, what exactly is causing the error? What can be done to fix or produce results I'm looking for within a UDT? I have tried commenting out the lines in which I utilize curly brackets but that does not fix the error. Here is the code -
current_value = system.tag.readBlocking(["[.]Current Value"])[0].value
#body = "Current Value = {current_val}".format(current_val = current_value)
body = ''
if currentValue.value == 'Upper Alert':
body = body + '\nIn Upper Alert State\n'
elif currentValue.value == 'Upper Alarm':
body = body + '\nIn Upper Alarm State\n'
elif currentValue.value == 'Lower Alert':
body = body + '\nIn Lower Alert State\n'
elif currentValue.value == 'Lower Alarm':
body = body + '\nIn Lower Alarm State\n'
else :
body = body + ' Compliant'
if currentValue.value == 'Compliant' or previousValue.value == 'Compliant':
system.tag.writeBlocking(["[.]Time Stamp"], system.date.now())
Email_Notification.send_email(
from_addr="automation@",
to_addr=[recipients],
subject = "My Devices Alert",
body=body,
cc_addr=[cc_recipients],
body_type = 'html'
)
The script is on a tag value change and the error appears in the diagnostics section, nothing appears in logs but the script just never runs even when tag changes. -
The value I read in should be used in that commented out line, I commented this out because the error mentions parameters and I know curly brackets can be used to call parameters
Email_Notification is a script I wrote and use in many other places, it is inherited by this project and sits in my project library.
Not in Python, curly brakets are syntax for a Dictionary or a Set. In this case it would have been a Set. Not true when the braces are included in a string...aggravating to miss that.
Assuming the script you provided is the full script, then you have several undefined identifiers.
current_value
recipeints
cc_recipients
Tags are outside of normal Project Scope, and so any scripts that are called must either be built-ins, defined by objects, or defined in the Global Scripting project. You say that Email_Notification is inherited by this project, Is the parent project the Global Scripting project?
A NullPointerException is basically always a bug in Ignition, not something for you to fix, but what version are you using? It's possible it's already fixed.
#body = "Current Value = {current_val}".format(current_val = current_value)
Once I remove this the error goes away, does not matter if it is commented out or not. Is there another way to format the strings in scripting without using curly brackets?
Looks to be the same, my search parameters were off because I initially didn't realize the curly brackets were the cause.
Hopefully if someone searches that error in the future this thread pops up. The multiple sources of finding errors can get annoying, I always look into the logs and forget diagnostics is also a place to look.