How do you make a gateway script counter to count in seconds and write that time to a tag? I want the trigger for the counter to be on/off state of a multistate indicator.
You could have a boolean “enable” tag that is set by the multistate indicator. Then a “count” tag to store the seconds value. In a 1000 ms gateway timer script put the following:
if(system.tag.read("enable").value == 1):
system.tag.write("count", system.tag.read("count").value + 1)
You will need to handle rollovers.
Consider recording start and stop timestamps to be precise. Something like this thread.
1 Like