Can't Evaluate Tag Value

Not sure what is happening here. All I want to do is test a tag value using a gateway script. I can’t seem to get consistent results. tagTest is a boolean, BTW:

[code]tagTest = system.tag.read(“Junk/MyTags/tag1234”).value

if (tagTest) :
do_something_amazing()
elif not (tagTest) :
do_something_mediocre()
[/code]

I’m seeing that the not true portion evaluates but not the true portion. I can set the tag manually and then run the script. One weirdness is I have Ignition 7.6.4 and I’m using Java 8 (because other software tools on my laptop require v8). I get some weird console/client errors when I open and close windows but I figure that’s because the versions of Java and Ignition are not getting along. I could definitely downgrade to Java v7 but was just wondering if this is a known thing or just the usual crop circles/satanic portal/bad programming from the general location of my cubicle.

First check your tag read results.

tagTest = system.tag.read("Junk/MyTags/tag1234") print tagTest.quality print tagTest.value print type(tagTest)

That might provide some insight. Perhaps the tag read is not getting the value you expect?

Also you don’t need the parenthesis. This should work just as well:

if tagTest.value: do_something_amazing() else: do_something_mediocre()

Edit: Should have been

print type(tagTest.value)

instead of

print type(tagTest)

I found a workaround: I used an expression tag to evaluate the tag that won’t cooperate and then I used my script to test the value of the expression tag.

Okay, I have a theory as to why this won’t work. Said “bad” tag is a custom data instance (“BI”). When I see the attributes for this type of tag it is indeed called out as a Boolean but its values are shown as “On” and “Off”. Maybe that’s why this test if (system.tag.read("Junk/MyTags/badTag").value == True) : doesn’t woik. Maybe the expression tag is converting the value to boolean so that the spice can flow.