Expression evaluates differently on two different Vision clients

I have an expression

if(dateDiff(tag({svc_status.tagPath} + "/timestamp"), now(), "seconds") < 10, 0, 2)

That I am using to set the state on an indicator. On my laptop in both designer and client, this evaluates correctly. However, on another laptop client, it does not evaluate correctly. I don't know exactly how it is not evaluating correclty, other than my client/designer evaluates to 0 and the other client seems to evaluate to 2 (based on the response from the widget, which changes color depending on the status value). Both clients are indicating the same current time, so I am not quite sure what could be misbehaving. My guess was some timezone shenanigans, which doesn't track with both clients (and operating systems) indicating the correct time.

The {svc_status.tagPath}+"/timestamp" tag is written to via a continually evaluated (every second) gateway script that is simply calling a Project Library script that is as follows:

def update_statuses():
	tcp2mqtt = json_decode(get_service_status("tcp2mqtt/status"))
	oscope = json_decode(get_service_status("oscope/status"))
	system.tag.writeBlocking([ 
		"[HMI]TB0/network/nasvc/tcp2mqtt/timestamp", 
		"[HMI]TB0/network/nasvc/tcp2mqtt/status", 
		"[HMI]TB0/network/nasvc/oscope/timestamp",
		"[HMI]TB0/network/nasvc/oscope/status"
		], [		
		system.date.parse(tcp2mqtt['timestamp'], "yyyy-MM-dd HH:mm:ssz"),
		tcp2mqtt['status'],
		system.date.parse(oscope['timestamp'], "yyyy-MM-dd HH:mm:ssz"),
		oscope['status']
		])

This is all fresh, active development code and is not in its final state.

That would indicate that the time is off between the two systems. Expression bindings, for the most part, are evaluated at the client level not the GW level. Tag expression bindings are at the Tag Level. Making this an expression tag should keep it from having a different result between two different clients.

1 Like

Consider using expression tags to evaluate the difference. Then it will remain the same regardless of client.

if(secondsBetween([HMI]TB0/network/nasvc/tcp2mqtt/timestamp, now()) < 10, 0, 2)
1 Like

This worked! Thank you. I should have done this from the beginning.