How to make tag timestamp to reference only from tag provider source

Hi All

I am using a edge v8.0.16 and a server v8.0.16 with MQTT modules.
On my edge, i have a counter tag ‘EdgeTag’ with updated seconds, so that the tag’s timestamp will be constantly updated.
I also have a ‘FromServerTag’ tag, so that its value can be written from server.

On my server, i have a counter expression tag ‘ServerTag’ : dateFormat(now(), ‘ss’).
I have created a server gateway timer script such that every 5 seconds, the value from ‘ServerTag’ will be written to ‘FromServerTag’

From the edge, I will then compare the timestamp of both ‘EdgeTag’ and ‘FromServerTag’. If the seconds between them are less than 10s, it means that the communication to the server is healthy.

However, i realised that the server is slower by 2mins, and the timestamp of ‘FromServerTag’ is referencing to the server as well (due to being written from the server), instead of using the edge’s system time.
In this case, when i compare the timestamp seconds between 2 tags, it would always be greater than 10s, even if the communication is fine…

Is there a way I could configure the tags such that the tag timestamp will only reference from the tag provider (edge)?

Use an expression tag to look at the timestamps.

abs(dateDiff({[~]EdgeTag.Timestamp}, {[~]FromServerTag.Timestamp}, 'seconds'))

Hi Jordan, thank you for replying.
I have attached a screenshot of the 2 tags below:
Local Counter = ‘EdgeTag’
Server Counter = ‘FromServerTag’


As you can see, Server Counter’s timestamp is slow by 2 mins, even if it was updated no less than 10 seconds before EdgeTag. But due to server side itself is slowed by 2 mins, so the timestamp is somehow affected, and hence seems to have a 2 mins delay.

It is taking the timestamp from the server instead, as it was written from the server side.
Hence even if i use the expression that you have provided, it would not work…

I have tried to use another memory tag ‘Server Counter Ref’, referencing to Server Counter Tag.
In this way, when ‘Server Counter’ is being updated, ‘Server Counter Ref’ will also be updated, and its timestamp will be using the time from Edge.

But i am hoping to reduce unnecessary steps if possible…

Instead of comparing tag timestamps, have the server gateway timer script write to a boolean tag on the edge gateway, something like “serverUpdateFlag”. Put a tag change event on this that writes now() to “serverUpdateTime” datetime tag. Then you can have an expression tag that looks at the timediff in seconds between now() and “serverUpdateTime”. If the diff is < 10 seconds, comms between edge and server are healthy.

Hi Dustin, thank you for suggesting this idea!

Actually i am also hoping to understand how the timestamp works.
The time that it reference from is it solely based on which source (the server/edge gateway) is writing to it?.. Because i do not understand why, when the tag ‘belongs’ to the edge, but upon written by server, it is taking the timestamp from server, instead of referencing to its source gateway instead…

I assume it’s by design as part of the tag structure.
What abut syncing your clocks to the same source?