Tag value change and quality control

Hello.

I am trying to avoid the trigger of a value change script when the tag value did not change but was the quality.

now I have the following at the beginning:
if not initialChange and currentValue.quality==192 and currentValue.value==True and previousValue.value==False:

I still have the doubt if in the case the quality of the tag changes meanwhile it is True it could trigger again... not sure.

The conditions will be meet, value is True, Quality is good, previousValue was False...

Just not initialChange and currentValue.value <> previousValue.value should do it.

You may need to do your own previous value tracking, to capture the last good value for your comparison. You should also be using the quality element's good attribute, and you should never compare to True or False.

When using separate tracking of previous values, you do not exclude the initial change.

Something like this:

if currentValue.quality.good:
	previous = system.tag.readBlocking(['[.]PreviousMemory'])[0].value
	system.tag.writeBlocking(['[.]PreviousMemory'], [currentValue.value])
	if currentValue.value and not previous:
		# Do your thing

Hello.

I use the value because it is a bool, it is a sensor, when sensor is true or false.

The issue I have seen is the following.
Time 0, sensor is true and quality is good, value change triggers and I sent event according.
Time 1, sensor is true and quality is bad, I have not seen a event.
Time 2, sensor is true as it was and quality is good again, another event is sent.

Conditions are not initial and value is true.