-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflow.json
90 lines (90 loc) · 3.8 KB
/
flow.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
[{
"id": "8b5844a8.98ceb",
"type": "websocket-client",
"z": "f6a99b89.ee40b8",
"path": "ws://192.168.178.8:8082/socket",
"wholemsg": "false"
},
{
"id": "da27812f.a869e",
"type": "mqtt-broker",
"z": "f6a99b89.ee40b8",
"broker": "192.168.178.8",
"port": "1883",
"clientid": "node_red",
"usetls": false,
"verifyservercert": true,
"compatmode": false,
"keepalive": "60",
"cleansession": true,
"willTopic": "",
"willQos": "0",
"willRetain": null,
"willPayload": "",
"birthTopic": "",
"birthQos": "0",
"birthRetain": null,
"birthPayload": ""
},
{
"id": "2a0bf3da.86486c",
"type": "debug",
"z": "f6a99b89.ee40b8",
"name": "",
"active": true,
"console": "false",
"complete": "payload",
"x": 470,
"y": 180,
"wires": []
},
{
"id": "c96f99e5.7e0f68",
"type": "mqtt out",
"z": "f6a99b89.ee40b8",
"name": "Push to Mosquitto",
"topic": "",
"qos": "0",
"retain": "false",
"broker": "da27812f.a869e",
"x": 190,
"y": 260,
"wires": []
},
{
"id": "46a539c8.f9ef08",
"type": "debug",
"z": "f6a99b89.ee40b8",
"name": "",
"active": false,
"console": "false",
"complete": "payload",
"x": 390,
"y": 100,
"wires": []
},
{
"id": "92d0eee7.2a6508",
"type": "function",
"z": "f6a99b89.ee40b8",
"name": "Format payload for influxdb",
"func": "/* Parses Json and formats data to be send to influxdb via \n* telegraf mqtt plugin\n* topic = topic used for mqtt\n* measurement = measurement in influxdb\n* tagX = tag information in influxdb\n*/\n\nvar uuidMap = {\n 'XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX':{\n topic:'/power/sml/Leistung',\n\t\tmeasurement:'power_sml',\n\t\ttags:{\n\t\t\ttag1:'Type=sml',\n\t\t\ttag2:'Location=Leistung'\n\t\t}\n },\n 'XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX':{\n topic:'/power/sml/Bezug',\n\t\tmeasurement:'power_sml',\n\t\ttags:{\n\t\t\ttag1:'Type=sml',\n\t\t\ttag2:'Location=Bezug'\n\t\t\ttag3:'bla'\n\t\t}\n },\n 'XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX':{\n topic:'/power/sml/Lieferung',\n\t\tmeasurement:'power_sml',\n\t\ttags:{\n\t\t}\n },\n 'XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX':{\n topic:'/power/s0/pv',\n\t\tmeasurement:'power_s0',\n\t\ttags:{\n\t\t\ttag1:'',\n\t\t\ttag2:''\n\t\t}\n },\n 'XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX':{\n topic:'/power/s0/og',\n\t\tmeasurement:'power_s0',\n\t\ttags:{\n\t\t\ttag1:'Type=s0',\n\t\t\ttag2:'Location=og'\n\t\t}\n },\n 'XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX':{\n topic:'/power/s0/eg',\n\t\tmeasurement:'power_s0',\n\t\ttags:{\n\t\t\ttag1:'Type=s0',\n\t\t\ttag2:'Location=eg'\n\t\t}\n },\n 'XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX':{\n topic:'/power/s0/ug',\n\t\tmeasurement:'power_s0',\n\t\ttags:{\n\t\t\ttag1:'Type=s0',\n\t\t\ttag2:'Location=ug'\n\t\t}\n }\n}; \n\n// Parse JSON \nvar myJsonObj = [];\nvar myJsonObj = JSON.parse(msg.payload);\n\n// Get value, timestam and UUID\nvar myUuid = myJsonObj.data.uuid;\nvar myTimestamp = myJsonObj.data.tuples[0][0];\nvar myValue = myJsonObj.data.tuples[0][1];\n\n// Dynamically read tags from uuidMap\nvar myTags =[];\nfor(var i in uuidMap[myUuid]['tags'])\n{\n\tif (uuidMap[myUuid]['tags'][i].length > 0) \n\t{\n\t\tmyTags.push(uuidMap[myUuid]['tags'][i]);\n\t}\n}\nvar myTagLine = myTags.join(\",\");\n\n// Create output payload\t\nvar myOutput = {};\nmyOutput.topic = uuidMap[myUuid]['topic'];\nmyLine1 = uuidMap[myUuid]['measurement'] + (myTagLine.length==0? '':','+ myTagLine);\nmyLine2 = \"value=\" + myValue + \" \" + (myTimestamp*1000000);\nmyOutput.payload = myLine1 + \" \" + myLine2;\nreturn myOutput;\n\t",
"outputs": 1,
"noerr": 6,
"x": 220,
"y": 180,
"wires": [["2a0bf3da.86486c",
"c96f99e5.7e0f68"]]
},
{
"id": "69806b97.448f4c",
"type": "websocket in",
"z": "f6a99b89.ee40b8",
"name": "Connect to VZ push-server",
"server": "",
"client": "8b5844a8.98ceb",
"x": 150,
"y": 100,
"wires": [["46a539c8.f9ef08",
"92d0eee7.2a6508"]]
}]