I've had to use the "System.tag.read" to get the value of the tag within the "Value Changed" script because "currentValue" is inconsistent. When I use it with an if statement it always thinks it's true, when I use it with "System.tag.write" it writes the value I expect.
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
#cv = system.tag.read("[default]Oscillators/%s" % (machine)).value
cv = currentValue
if cv
system.tag.write("[default]New Tag", 1)
else:
system.tag.write("[default]New Tag", 0)
Whether the value of the tag is true or false, it still writes 1 to the new tag.
If it's done like this though, it works as expected so New Tag becomes true or false depending on the value of the tag changing.
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
cv = system.tag.read("[default]Oscillators/%s" % (machine)).value
#cv = currentValue
if cv
system.tag.write("[default]New Tag", 1)
else:
system.tag.write("[default]New Tag", 0)
But somehow this also works.
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
system.tag.write("[default]New Tag", currentValue)