# Trigger a memory tag / OPCUA tag for N seconds and turn off

**URL:** <https://forum.inductiveautomation.com/t/trigger-a-memory-tag-opcua-tag-for-n-seconds-and-turn-off/112383>\
**Category:** Ignition\
**Tags:** ignition79, ignition80, scripting, perspective\
**Created:** [November 24, 2025, 9:42am UTC](https://forum.inductiveautomation.com/t/trigger-a-memory-tag-opcua-tag-for-n-seconds-and-turn-off/112383 "2025-11-24T09:42:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![tejas200010](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tejas200010/32/81552_2.png) [@tejas200010](https://forum.inductiveautomation.com/u/tejas200010)\
**Post date:** [November 24, 2025, 9:42am UTC](https://forum.inductiveautomation.com/t/trigger-a-memory-tag-opcua-tag-for-n-seconds-and-turn-off/112383/1 "2025-11-24T09:42:18Z")

</div>

Hi, I am working in Ignition Perspective and I want to turn an OPC UA Boolean tag ON only for 2 seconds when a button is pressed, and then turn it OFF automatically.

I wrote this script under **Button → onActionPerformed → `runAction`** :

def runAction(self, event):  
tagPath = "[default]MyFolder/MyPulseTag"

```python
def pulseTag():
    import time
    system.tag.writeBlocking([tagPath], [True])
    time.sleep(2)
    system.tag.writeBlocking([tagPath], [False])

system.util.invokeAsynchronous(pulseTag)

```

This is working fine.

My main doubts are:

1. Is this approach safe and recommended?

2. Does `invokeAsynchronous()` ensure that the UI/session thread is not blocked during the `time.sleep(2)`?

3. Is there a better way to create a 2-second pulse on a tag?

Thanks in advance.

---

<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:** [November 24, 2025, 1:21pm UTC](https://forum.inductiveautomation.com/t/trigger-a-memory-tag-opcua-tag-for-n-seconds-and-turn-off/112383/2 "2025-11-24T13:21:22Z")

</div>

1. Safe if only one user can push the button. And you disable the button to prevent multiple close presses. Not recommended.
2. Yes.
3. There is no **good** way to do this from a message-based multi-user SCADA.

The **right** answer is to have the target device turn the signal off after two seconds. So that no second message is required. A common flaw encountered with this pattern is a failure or disruption of the second message, leaving the process in a bad state. (Very similar to the problems with momentary buttons.)

If I absolutely had to do this, I'd use a gateway timer event to run PLC-ish logic to write the "off" message repeatedly if there are errors.

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [November 24, 2025, 2:39pm UTC](https://forum.inductiveautomation.com/t/trigger-a-memory-tag-opcua-tag-for-n-seconds-and-turn-off/112383/3 "2025-11-24T14:39:15Z")

</div>

I’d do this with 2 tags.

1. Tag you want to write
2. Tag for a timestamp when the button is pressed

I’d make a button that writes (1) to your tag and writes the current time to a memory tag. Have a gateway event that checks the value of your tag. If it’s 1, check the timestamp tag vs the current time. If enough time has elapsed write it back to 0. If it’s 0, do nothing.

Could add a 3rd tag for the time setpoint if you want.

Of course, like Phil said this would ideally be done in the PLC.

Would be cool it there was a way to entirely disable/enable the gateway script based on the target tag’s value.

---

<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:** [November 24, 2025, 2:51pm UTC](https://forum.inductiveautomation.com/t/trigger-a-memory-tag-opcua-tag-for-n-seconds-and-turn-off/112383/4 "2025-11-24T14:51:55Z")

</div>

> [@amarks](#):
>
> entirely disable/enable the gateway script

The best approach with the least overhead is to make **one** gateway timer event containing **all** such logic in your system.

Have it do a single `system.tag.readBlocking()` at the beginning to get all tag values of interest. Conditionally call subroutines based on current states. Assemble two lists, of tag paths and values, to include in a **single** `system.tag.writeAsync()` at the end of the event script's library function.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [November 24, 2025, 8:27pm UTC](https://forum.inductiveautomation.com/t/trigger-a-memory-tag-opcua-tag-for-n-seconds-and-turn-off/112383/5 "2025-11-24T20:27:57Z")

</div>

> [@pturmel](#):
>
> 1. Yes.

Yes for Vision, but Being perspective, no script action will block the gui since perspective clients run in the gateway and use multiple spawned worker threads to execute user action scripts along with everything else it needs (I'm not explaining that to _you_ btw Phil, since you can do a far better job than I can haha, but to the OP)

---

<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:** [November 24, 2025, 9:41pm UTC](https://forum.inductiveautomation.com/t/trigger-a-memory-tag-opcua-tag-for-n-seconds-and-turn-off/112383/6 "2025-11-24T21:41:47Z")

</div>

> [@nminchin](#):
>
> but Being perspective ....

Moot if the OP changes to a proper approach. Which is why I dropped the nuances.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [November 24, 2025, 10:21pm UTC](https://forum.inductiveautomation.com/t/trigger-a-memory-tag-opcua-tag-for-n-seconds-and-turn-off/112383/7 "2025-11-24T22:21:14Z")

</div>

Always good to understand though for other things
