# Gateway Tag Change Scripts

**URL:** <https://forum.inductiveautomation.com/t/gateway-tag-change-scripts/5648>\
**Category:** Ignition\
**Created:** [January 4, 2013, 9:54pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-scripts/5648 "2013-01-04T21:54:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmonter](https://avatars.discourse-cdn.com/v4/letter/j/858c86/32.png) [@jmonter](https://forum.inductiveautomation.com/u/jmonter)\
**Post date:** [January 4, 2013, 9:54pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-scripts/5648/1 "2013-01-04T21:54:33Z")

</div>

Hello,  
I have a gateway tag change script that is looking at the change of an alarm tag, I want to make it execute only when the alarm is true and not when the alarm is false. Here is my script but for some reason it is still executing when the alarms goes true and when the alarms goes back to false.

[color=#0040BF]Alarm = system.tag.getTagValue(“system1/project1/HTST\_1/ALARMS/MILK\_TOO\_HOT”)  
curHour = system.tag.getTagValue(“curTime”)  
Temp = system.tag.getTagValue(“system1/project1/HTST\_1/Analog/TT130177\_SCL”)  
body="Pasturized Milk Temp @ " + str(Temp)+ “°F for over 10 min”

if curHour \> 9 :  
recipients = [“xxxxx@txt.att.net”,“xxx@txt.att.net”]  
else :  
recipients = [“xxxx@txt.att.net”]

if Alarm :  
system.net.sendEmail(smtp=“smtp.xxx”, [from="alarms@xxxx.com](mailto:from=%22alarms@xxxx.com)", subject=“Pasturized Milk Temp High”, body=body,html=0, [to=recipients,username="alarms@xxx.com](mailto:to=recipients,username=%22alarms@xxx.com)",password=“xxxx”)[/color]

What amd I doing wrong?

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [January 4, 2013, 9:58pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-scripts/5648/2 "2013-01-04T21:58:31Z")

</div>

It should be something like:[code]if newValue.value == 1:  
curHour = system.tag.getTagValue(“curTime”)  
Temp = system.tag.getTagValue(“system1/project1/HTST\_1/Analog/TT130177\_SCL”)  
body="Pasturized Milk Temp @ " + str(Temp)+ “°F for over 10 min”

```
if curHour > 9 :
    recipients = ["xxxxx@txt.att.net","xxx@txt.att.net"]
else :
    recipients = ["xxxx@txt.att.net"]

system.net.sendEmail(smtp="smtp.xxx", from="alarms@xxxx.com", subject="Pasturized Milk Temp High", body=body,html=0, to=recipients,username="alarms@xxx.com",password="xxxx")[/code]
```

---

<div class="post-metadata">

**Author:** ![jmonter](https://avatars.discourse-cdn.com/v4/letter/j/858c86/32.png) [@jmonter](https://forum.inductiveautomation.com/u/jmonter)\
**Post date:** [January 4, 2013, 10:02pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-scripts/5648/3 "2013-01-04T22:02:12Z")

</div>

Thanks,  
How about when the script is driven by two tags?

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [January 5, 2013, 1:06am UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-scripts/5648/4 "2013-01-05T01:06:53Z")

</div>

You can look at the tag’s name or tag path. Take a look at this page:

[inductiveautomation.com/supp … cripts.htm](http://www.inductiveautomation.com/support/usermanuals/ignition/index.html?tag_change_scripts.htm)

You can use event.tagPath.itemName or str(event.tagPath) in your script.
