# Node-red-contrib-opcua: set source timestamp

**URL:** <https://discourse.nodered.org/t/node-red-contrib-opcua-set-source-timestamp/79703>\
**Category:** General\
**Created:** [10 July 2023 15:11 UTC](https://discourse.nodered.org/t/node-red-contrib-opcua-set-source-timestamp/79703 "2023-07-10T15:11:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![yoba](https://avatars.discourse-cdn.com/v4/letter/y/57b2e6/32.png) [@yoba](https://discourse.nodered.org/u/yoba)\
**Post date:** [10 July 2023 15:11 UTC](https://discourse.nodered.org/t/node-red-contrib-opcua-set-source-timestamp/79703/1 "2023-07-10T15:11:53Z")

</div>

Hi,

I'm using node RED as a gateway between an API and OPC UA. Node RED receives values from API with a timestamp. I'm successfully writing values to a variable "vannstand" on opc ua server from node red, but i struggle to forward the timestamp as "sourceTimestamp" attribute. I tried different format but no one succeeded.  
From blockquote under, the timestamp should be 10/07/2023, 16:00:00 [UTC+2]. Here is the payload sent to OPC UA server node:

```auto
msg.payload= {"namespace": 2, "messageType": "Variable", 
                "variableName": "Vannstand",
                "variableValue": 1.6,
                "sourceTimestamp": 1688997600000}}
return msg;

```

But my opc ua client shows only current time. Here is the result when injecting the node at 16:31:

 ![bilde](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/9/695341cc0f141c81ea7e4b3f0452038d691e2bb0.png)

Could someone tell me if opc ua server is able to receive "sourceTimestamp" attribute?

P.S: I found the solution. The problem was due to a missing attribute. By adding "quality" attribute in the payload, the OPCUA server accept "sourceTimestamp":

```auto
msg.payload= {"namespace": 2, "messageType": "Variable", 
                "variableName": "Vannstand",
                "variableValue": 1.6,
                "sourceTimestamp": 1688997600000,
                "quality": "Good"}}
return msg;

```

Regards,

Yoann

---

<div class="post-metadata">

**Author:** ![mikakaraila](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mikakaraila/32/37496_2.png) [@mikakaraila](https://discourse.nodered.org/u/mikakaraila)\
**Post date:** [13 August 2023 17:20 UTC](https://discourse.nodered.org/t/node-red-contrib-opcua-set-source-timestamp/79703/2 "2023-08-13T17:20:44Z")

</div>

Have not checked, but try "sourceTimestamp": new Date(168899760000),

I expect those field require DateTime not ms.

---

<div class="post-metadata">

**Author:** ![rknasr](https://avatars.discourse-cdn.com/v4/letter/r/ecc23a/32.png) [@rknasr](https://discourse.nodered.org/u/rknasr)\
**Post date:** [25 September 2023 15:19 UTC](https://discourse.nodered.org/t/node-red-contrib-opcua-set-source-timestamp/79703/3 "2023-09-25T15:19:57Z")

</div>

Hello,  
Following up on this issue, I have deployed an OPC UA server using the OPC UA server node, and injected values to certain nodes. Upon writing a value to a node in my OPC UA server, and assigning a source timestamp, there seems to be a possible bug. The source timestamp assigned is being written to the server timestamp instead. The value is written sucessfully to this node, but the source Timestamp is being written to the server timestamp. this is the current payload sent to the opc ua server:

msg.payload= {" **namespace**": 10,  
" **messageType**": "Variable",  
" **variableName**":""Objects"."DeviceSet"."AssemblySystem01"."Assets"."Tools"."Value"",  
" **variableValue**": 47,  
" **sourceTimestamp**": 1688997600000,  
" **quality**": "Good"}  
return msg;

Also below is the result when accessed with an OPC UA client:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/9/69c7d26a9802affaa8ac56fc9cfdb26d3d587ce0.png)

---

<div class="post-metadata">

**Author:** ![mikakaraila](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mikakaraila/32/37496_2.png) [@mikakaraila](https://discourse.nodered.org/u/mikakaraila)\
**Post date:** [26 September 2023 18:34 UTC](https://discourse.nodered.org/t/node-red-contrib-opcua-set-source-timestamp/79703/4 "2023-09-26T18:34:48Z")

</div>

Just fixed this one to v0.2.315

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [25 November 2023 18:35 UTC](https://discourse.nodered.org/t/node-red-contrib-opcua-set-source-timestamp/79703/5 "2023-11-25T18:35:47Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
