Tag Event Script Value Changed But Only If Change Was X Minutes Ago

Hello I am trying to record the timestamp when a boolean tag changes value, but only if the most recent change was more than x seconds ago. I am trying to exclude moments when the tag changes rapidly. Is there a way to do that?

Is there anything that can be done with this?

time = currentValue.timestamp - previousValue.timestamp


Take a look at this.

offTime = currentValue.timestamp
onTime = previousValue.timestamp
time = system.date.minutesBetween(onTime, offTime)

if currentValue.value == 1 and time > 5:
system.tag.write("[.]Direct Steam On Timestamp",system.date.now())

Thanks! This helped!