Hello everyone,
I want to write Data from csv with the following format to a influx db.
Example:
Time,TS1,TS2,RO1,Heatquantity1,Heatquantity2,CO2Savings,Errors
2020-01-02T00:00,3.0,14.6,0,977,977,234,0
How can you program the the function node, to import the fields to the influx database (with timestamp from csv)?
my actual flow:
[
{
"id": "a2a16dc6.fbd32",
"type": "function",
"z": "66faf3265599a6a5",
"name": "Ready for next lines",
"func": "return [\n msg.complete ? msg : null,\n { tick: true },\n];\n",
"outputs": 2,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 930,
"y": 400,
"wires": [
[
"87fbc09b.6deeb",
"35615002.196b78"
],
[
"e6ec0f0a.388198"
]
]
},
{
"id": "436dce51.065f6",
"type": "csv",
"z": "66faf3265599a6a5",
"name": "",
"sep": ",",
"hdrin": true,
"hdrout": "none",
"multi": "mult",
"ret": "\\n",
"temp": "Time,TS1,TS2,RO1,Heatquantity1,Heatquantity2,CO2Savings,Errors",
"skip": "0",
"strings": false,
"include_empty_strings": "",
"include_null_values": "",
"x": 420,
"y": 460,
"wires": [
[
"ac588056e821047b"
]
]
},
{
"id": "87fbc09b.6deeb",
"type": "debug",
"z": "66faf3265599a6a5",
"name": "Done",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "true",
"targetType": "full",
"statusVal": "_parts.lines",
"statusType": "msg",
"x": 1160,
"y": 460,
"wires": []
},
{
"id": "35615002.196b78",
"type": "ui_text",
"z": "66faf3265599a6a5",
"group": "5368deb4.54dba",
"order": 3,
"width": 0,
"height": 0,
"name": "",
"label": "Lines uploaded:",
"format": "{{msg._parts.lines}}",
"layout": "row-spread",
"className": "",
"x": 1190,
"y": 400,
"wires": []
},
{
"id": "e6ec0f0a.388198",
"type": "chunks-to-lines",
"z": "66faf3265599a6a5",
"name": "",
"nbLines": "4096",
"linesFormat": "csv",
"decoder": "UTF-8",
"x": 270,
"y": 460,
"wires": [
[
"436dce51.065f6"
]
]
},
{
"id": "4b31cec2.dad2c8",
"type": "ui_upload",
"z": "66faf3265599a6a5",
"group": "5368deb4.54dba",
"title": "Generic upload to influxdb",
"name": "uploadinflux",
"order": 3,
"width": 6,
"height": 6,
"chunk": "256",
"transfer": "binary",
"x": 100,
"y": 460,
"wires": [
[
"e6ec0f0a.388198"
]
]
},
{
"id": "fb8cb419d5357944",
"type": "Stackhero-InfluxDB-v2-write",
"z": "66faf3265599a6a5",
"server": "48657b1033c65a79",
"name": "",
"x": 820,
"y": 480,
"wires": [
[
"a2a16dc6.fbd32"
]
]
},
{
"id": "c0a0e415fdd8fb83",
"type": "debug",
"z": "66faf3265599a6a5",
"name": "csv to db",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 570,
"y": 600,
"wires": []
},
{
"id": "ac588056e821047b",
"type": "function",
"z": "66faf3265599a6a5",
"name": "format influx",
"func": "// create object and populate with Influx tags\nvar tags = {}\ntags.node = msg.node\ntags.device = msg.device\ntags.location = msg.location\n\n// create object for measurement values\nvar v = {}\nv.value = msg.payload // the measurement value\n\n// create and fill array for the payload\nvar arr = [] \narr[0] = v // the measurement value\narr[1] = tags\n\n// put the array into msg.payload and send it off\nmsg.payload = arr\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 590,
"y": 480,
"wires": [
[
"fb8cb419d5357944",
"c0a0e415fdd8fb83"
]
]
},
{
"id": "5368deb4.54dba",
"type": "ui_group",
"name": "Außen",
"tab": "9b1688bfbf5d67fb",
"order": 4,
"disp": true,
"width": "9"
},
{
"id": "48657b1033c65a79",
"type": "Stackhero-InfluxDB-v2-Server",
"name": "Test",
"host": "192.168.172.221",
"port": "8086",
"tls": false,
"credentials": {},
"info": "SHOW SERIES"
},
{
"id": "9b1688bfbf5d67fb",
"type": "ui_tab",
"name": "Home",
"icon": "dashboard",
"order": 1,
"disabled": false,
"hidden": false
}
]
Can someone help please?
Thank You
Holger