Setting a variable to 5 seconds from a button in perspective

Hi.
I have a problem with calling the setting of a tag from a button in perspective to true for 5 seconds. I would like to set the tag to true for 5 seconds and then have it return to false after 5 seconds. I manage to set tag to true, but it does not return to false after 5 seconds.

My code under the mouse event button

system.perspective.print("Start script:")

tagPath = "[Ignition_IO_01_NE_KRASNOPOL]NE_KRASNOPOL/LV_On"
system.perspective.print("Set path")

system.tag.writeBlocking([tagPath], [True])
system.perspective.print("Set tag")


system.util.invokeLater(
	lambda: system.tag.writeBlocking([tagPath], [False]),
	5000  # opóźnienie w milisekundach
)

system.perspective.print("Reset tag")

Unfortunately the variable does not return to false after 5 seconds

system.util.invokeLater() doesn't exist in gateway or Perspective scope. It is a Vision-only function.

What function should i use to reset the tag after 5 seconds?

If you want it to be reliable, you should use:

  • A memory tag that holds the desired future turn-off time, and
  • A timer event that checks that and the current state to write the off state when the turn off time is reached. Run that timer event all the time, at a pace that yields the desired precision.