Note the data is in msg.data
. On my system there is about 10 - 11 milliseconds difference because of the number of MQTT nodes between the two. If I add one node after another that difference drops to 2 milliseconds
[{"id":"31aadcfc53f96ec7","type":"debug","z":"6938459deb189e43","name":"Tester","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":610,"y":2260,"wires":[]},{"id":"c421576e353fedeb","type":"mqtt in","z":"6938459deb189e43","name":"Smart Socket 01 Status In","topic":"tuya2mqtt/Smart Socket 01/status","qos":"2","datatype":"auto-detect","broker":"ee05e0d9.9118e","nl":false,"rap":true,"rh":0,"inputs":0,"x":150,"y":2260,"wires":[["f8879a5a373ff9a5"]]},{"id":"f8879a5a373ff9a5","type":"change","z":"6938459deb189e43","name":"Tuya Data to Payload","rules":[{"t":"set","p":"data","pt":"msg","to":"$type(payload.data.dps.\"19\") = \"number\" ? {\"voltage\": payload.data.dps.\"20\" / 10, \"current\": payload.data.dps.\"18\" / 1000, \"power\": payload.data.dps.\"19\" / 10, \"last_seen\": $millis()} : 0","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"data.power","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":2260,"wires":[["31aadcfc53f96ec7"]]},{"id":"f17a3325d0a7dab2","type":"mqtt in","z":"6938459deb189e43","name":"Smart Socket 01 Status In","topic":"tuya2mqtt/Smart Socket 01/status","qos":"2","datatype":"auto-detect","broker":"ee05e0d9.9118e","nl":false,"rap":true,"rh":0,"inputs":0,"x":150,"y":2320,"wires":[["e3e9cd2f29690baa"]]},{"id":"d17a3dcf9f8027e2","type":"debug","z":"6938459deb189e43","name":"MQTT In","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":620,"y":2320,"wires":[]},{"id":"e3e9cd2f29690baa","type":"change","z":"6938459deb189e43","name":"Tuya Data to Payload","rules":[{"t":"set","p":"data","pt":"msg","to":"$type(payload.data.dps.\"19\") = \"number\" ? {\"voltage\": payload.data.dps.\"20\" / 10, \"current\": payload.data.dps.\"18\" / 1000, \"power\": payload.data.dps.\"19\" / 10, \"last_seen\": $millis()} : 0","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"data.power","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":2320,"wires":[["d17a3dcf9f8027e2"]]},{"id":"ee05e0d9.9118e","type":"mqtt-broker","name":"MQTT","broker":"192.168.1.21","port":"1883","clientid":"","autoConnect":true,"usetls":false,"compatmode":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]
The input message is; (although this was just what I was using. The input and the change node can be edited, as long as the change node adds $millis() to a msg property)
{"topic":"tuya2mqtt/Smart Socket 01/status","payload":{"data":{"devId":"6000521040f520dee7f7","dps":{"19":45,"20":2387},"t":1670360383},"deviceId":"6000521040f520dee7f7","deviceName":"Smart Socket 01"},"qos":1,"retain":false,"_msgid":"8a097bf4f19e70f5"}