Connection State Diagnostic Tag True/False Evaluation for Alarm

Hello,
I’m trying to evaluate whether a location in the field is connected or not with Connection Status diagnostic tag and then prompt an alarm if it’s disconnected.

The alarm is set to start for true.
I tried the following to configure the alarm but it’s not working:

conn = system.tag.read(“PumpingStation/Connection State.Value”)
if (conn = “Disconnected”, true, false)

If I test print this line in the script console, it returns ok the state connected or disconnected: system.tag.read(“PumpingStation/Connection State.Value”)

Any advice please?
Thanks.

You’re mixing up expressions and scripting.
If you’re inside of an alarm, you’re almost certainly using expressions - so the expression would be:

if({PumpingStation/Connection State} = "Disconnected", True, False)

The equivalent script would be:

conn = system.tag.read("PumpingStation/Connection State").value
if conn == "Disconnected":
	return True
else:
	return False
2 Likes