Hi community,
my first time in the forum since so far I was able to help myself (also thanks to the forum) but my current task is kind of challenging. The basic idea is kind of simple and I will explain on a minimum example: With Node-RED (using v4.0.2) I want to create a inject-pushed function, that gives a value (later different values) with a specific timestamp (defined by myself) to the influx Database (InfluxDB shell version 1.8.10) and get visualized by Grafana. The timestamp is always now+10s, so that the values are "already" in the dashboard.
[
{
"id": "2de6969d2c637700",
"type": "debug",
"z": "464b0d4053eb7bea",
"name": "debug 185",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 690,
"y": 1120,
"wires": []
},
{
"id": "3dc325a70c8f5e9a",
"type": "influxdb out",
"z": "464b0d4053eb7bea",
"influxdb": "50fec97b649b4aa5",
"name": "temperatur",
"measurement": "temperatur",
"precision": "",
"retentionPolicy": "",
"database": "database",
"precisionV18FluxV20": "ms",
"retentionPolicyV18Flux": "",
"org": "organisation",
"bucket": "bucket",
"x": 690,
"y": 1160,
"wires": []
},
{
"id": "2c7a4cc6b5e1cfc6",
"type": "inject",
"z": "464b0d4053eb7bea",
"name": "",
"props": [],
"repeat": "1",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 170,
"y": 1120,
"wires": [
[
"d517ee8d117e1942"
]
]
},
{
"id": "d517ee8d117e1942",
"type": "function",
"z": "464b0d4053eb7bea",
"name": "function 23",
"func": "let futureTimestamp = Date.now() + 60000; // Beispiel-Zeitstempel in der Zukunft (in Millisekunden)\nlet timestampNs = futureTimestamp * 1000000; // Umrechnung in Nanosekunden\n\n// Den Payload im Line Protocol Format fĂĽr InfluxDB setzen\nmsg.payload = -45;\nmsg.timestamp = timestampNs;\n\n// msg Objekt zurĂĽckgeben\nreturn msg;\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 410,
"y": 1120,
"wires": [
[
"2de6969d2c637700",
"3dc325a70c8f5e9a"
]
]
},
{
"id": "50fec97b649b4aa5",
"type": "influxdb",
"hostname": "127.0.0.1",
"port": "8086",
"protocol": "http",
"database": "enasensors",
"name": "enasensors",
"usetls": false,
"tls": "",
"influxdbVersion": "1.x",
"url": "http://localhost:8086",
"timeout": "10",
"rejectUnauthorized": true
}
]
Everything but the timestamp-transmission works. I really don't know how to format the payload, so that InfluxDB take my timestamp and not the systems one.
I am thankful for every hint and advice. So far I tested a lot but make no step forward.
Best regards and thanks in advance.