# Tag value change and quality control

**URL:** <https://forum.inductiveautomation.com/t/tag-value-change-and-quality-control/95370>\
**Category:** Ignition\
**Tags:** ignition81, scripting\
**Created:** [August 30, 2024, 1:41pm UTC](https://forum.inductiveautomation.com/t/tag-value-change-and-quality-control/95370 "2024-08-30T13:41:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jose\_Daniel\_Hernande](https://avatars.discourse-cdn.com/v4/letter/j/bbce88/32.png) [@Jose\_Daniel\_Hernande](https://forum.inductiveautomation.com/u/Jose_Daniel_Hernande)\
**Post date:** [August 30, 2024, 1:41pm UTC](https://forum.inductiveautomation.com/t/tag-value-change-and-quality-control/95370/1 "2024-08-30T13:41:44Z")

</div>

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...

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [August 30, 2024, 1:47pm UTC](https://forum.inductiveautomation.com/t/tag-value-change-and-quality-control/95370/2 "2024-08-30T13:47:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 30, 2024, 1:54pm UTC](https://forum.inductiveautomation.com/t/tag-value-change-and-quality-control/95370/3 "2024-08-30T13:54:03Z")

</div>

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:

```python
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

```

---

<div class="post-metadata">

**Author:** ![Jose\_Daniel\_Hernande](https://avatars.discourse-cdn.com/v4/letter/j/bbce88/32.png) [@Jose\_Daniel\_Hernande](https://forum.inductiveautomation.com/u/Jose_Daniel_Hernande)\
**Post date:** [August 30, 2024, 2:44pm UTC](https://forum.inductiveautomation.com/t/tag-value-change-and-quality-control/95370/4 "2024-08-30T14:44:55Z")

</div>

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.
