Delayed start after button


This might be a bit of a novice question but, I want the following to happen;

When I press the start button, a OPC UA tagg should be set to 1 at a certain time of day. This begin 06:00 - 14:00 - 22:00.
And this for the time while the button is pressed.

I took a toggle button (beceause it stays “pressed”) and put following code Event Handler actionPerformed. But if I press the button at for example 09:55, nothing happends at 10:00.

The idea behind is that when I release the toggle button, the script stops.

Ay help is welcome!

datum =,“yyyy-MM-dd”)
uur =
minuten =

NieuweLes6u = 1
NieuweLes14u = 1

if uur == 6 and minuten == 0 and NieuweLes6u == 1:
system.tag.write(‘PLC_WitMixer/MemoryTags/EenpuntNogNietGelezen’, 1)
NieuweLes6u = 0
if uur == 10 and minuten == 0 and NieuweLes14u == 1:
system.tag.write(‘PLC_WitMixer/MemoryTags/EenpuntNogNietGelezen’, 1)
NieuweLes14u = 0

One approach could be to have the button set a StartRequested memory tag to true.

Then in a gateway script you could check on that memory tag every 60 seconds. If it is True, and the time correct, then set the OPC tag to True, and set your StartRequested back to False so that you don’t trigger it is again.

You’re using system.tag.write in your script. This has been deprecated in v8.0 and up. Consider using system.tag.writeBlocking

1 Like

This worked fine! Thank you!

1 Like