# Gateway tag change script is getting triggered at random intervals

**URL:** <https://forum.inductiveautomation.com/t/gateway-tag-change-script-is-getting-triggered-at-random-intervals/89278>\
**Category:** Ignition\
**Tags:** scripting, ignition81\
**Created:** [April 23, 2024, 12:48pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-script-is-getting-triggered-at-random-intervals/89278 "2024-04-23T12:48:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_DeBate](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alex_debate/32/56483_2.png) [@Alex\_DeBate](https://forum.inductiveautomation.com/u/Alex_DeBate)\
**Post date:** [April 23, 2024, 12:48pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-script-is-getting-triggered-at-random-intervals/89278/1 "2024-04-23T12:48:43Z")

</div>

I have a gateway tag change event configured to a remote provider's tag that is getting triggered at random times. Digging through the logs, this appears to happen when the connection between the remote and local gateway drops and is then re-established. See the log below:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/2/3279da031d143a56044bcaa4f8412624f850a1da.png)

The script it triggers generates and distributes a report. Now, I _though_ that putting in some basic logic into the script would help weed out these accidental triggerings, but the report is still getting distributed regardless. See the event script below:

```python
date = system.date.now()
day = system.date.getDayOfWeek(date)

if not initialChange and newValue.getValue() == False and newValue.getValue() != previousValue.getValue() and (day > 1 and day < 7):
	#Script that executes and distributes the report went here

```

Anyone have any recommendations on fixing this? I figures that `newValue.getValue() != previousValue.getValue() ` would fix this, since the tag doesn't change during these events.

---

<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:** [April 23, 2024, 2:22pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-script-is-getting-triggered-at-random-intervals/89278/2 "2024-04-23T14:22:50Z")

</div>

What Change Triggers do you have it watching?

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/c/6c84eb3050419060a91fd2a03a7a3ac29c3430dc.png)

---

<div class="post-metadata">

**Author:** ![Alex\_DeBate](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alex_debate/32/56483_2.png) [@Alex\_DeBate](https://forum.inductiveautomation.com/u/Alex_DeBate)\
**Post date:** [April 23, 2024, 2:42pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-script-is-getting-triggered-at-random-intervals/89278/3 "2024-04-23T14:42:01Z")

</div>

Just value

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/2/52adb33d5449864dd160cfe1388bf0e9e6607990.png)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 23, 2024, 2:54pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-script-is-getting-triggered-at-random-intervals/89278/4 "2024-04-23T14:54:40Z")

</div>

Log the previous value and current value. I'd put money down that previous value is coming in as null when you see extra triggers.
