Error: Expected numeric value for, timestamp

Hallo

a mqtt into Node-Red --> into influx

i got a error like this

5.1.2021, 13:13:08node: 6d00231f.50158c
msg : error
"Error: Expected numeric value for, timestamp, but got '2021-01-05 12:13:10'!"

and the payload would be like this

5.1.2021, 13:13:08node: f5f2994b.a68ff8
/iot12/433MHz : msg.payload : Object
object
time: "2021-01-05 12:13:10"
brand: "OS"
model: "Oregon-THGR122N"
id: 126
channel: 2
battery_ok: 1
temperature_C: 1.9
humidity: 63

is there some magic to change the time on the fly?

have a nice day
vinc

Yes, it using a function node and writing the code to do it.

Have you done a google search with something like javascrpt convert string date/time to timestamp and looked how others have done this?

Try something like this in a function node.

[{"id":"83c682b8.032bc","type":"inject","z":"8d22ae29.7df6d","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"2021-01-05 12:13:10","payloadType":"str","x":210,"y":2580,"wires":[["e9247477.223b28"]]},{"id":"e9247477.223b28","type":"function","z":"8d22ae29.7df6d","name":"","func":"msg.payload = new Date(msg.payload).valueOf();\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":390,"y":2580,"wires":[["6d57c0db.f2671"]]},{"id":"6d57c0db.f2671","type":"debug","z":"8d22ae29.7df6d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":640,"y":2480,"wires":[]}]

If you are using the the influxdb node you can pass the time as a string, but I believe it should be in ISO 8601 format. so something like yyyy-MM-ddTHH:mm:ssZ

Edit: That is an alternative to providing a timestamp in ticks of course.

@Colin @E1cid @zenofmud
thanks for your Feedback, i will have to dig to understand to only change this "time" part of the payload

The best would be just to remove the time stamp - because it make problem and i it is 1h behind :wink:

have a nice day
vinc

If you are just adding data for the current time then you don't need a timestamp, influx will use the current time.

The one hour error was likely that you were providing a local time instead of UTC. Influx expects the timestamp in UTC.

@Colin
yes it would be just the current time - mqtt - Node Red - InfluxDB - the couple of second it need is not important.