I would have put this message in the original thread here
viewtopic.php?p=40126#p40126
(getting a Gateway script to run every minute exactly on the minute)
but it’s locked as I’d marked it as solved.
I followed JordanCClark’s advice, basically creating a tag that holds the minute value
using dateExtract(now(),“Minute”) with a fast update rate (250ms).
I’ve got an On Change script looking at this.
The issue I’ve got is that if in my script I reference [System]Gateway/CurrentDateTime
then I’m getting a value just fractionally before the change in minute.
E.g. say I expect my script to trigger at exactly 7:00:00 the value returned is 6:59:59.844
(this causes me a problem as it’s relating to detecting a shift change which happens at 7am)
So my question boils down to the expression function now() and the tag [System]Gateway/CurrentDateTime
returning different values. It’s all on the gateway so I assumed they’d be using the same clock.
Presumably this is some timing issue?
I’ve tried changing my expression from
dateExtract(now(),"Minute")
to
dateExtract({[System]Gateway/CurrentDateTime},"Minute")
I think this should sort my problem although I’m finding the value now returned within the script
is typically 800ms after the minute change - ultimately not a problem although I’d have thought with
a scan class of 250ms it would have been less.