First of all I want to receive the object from the MQTT broker, splitt them accordingly into fields and field values, show them in a dashboard and store then the field:value pairs with an timestamp into influx.
But I was not successfull so I tried to get the values from the broker by subscribe them individiually.
Now I have the JSON object:
27.12.2017, 17:44:50node: JSONbme280sensortest/devices/loranode1/up : msg.payload : Object
objectapp_id: "bme280sensortest"
dev_id: "loranode1"
hardware_serial: "0026BD7D7CD0A6CB"
port: 1
counter: 451
payload_raw: "AWcAtQJzJlkDaIwEAg1I"
payload_fields: objectanalog_in_4: 34
barometric_pressure_2: 981.7
relative_humidity_3: 70
temperature_1: 18.1
and here is my flow:
[
{
"id": "1805cb4e.d51d25",
"type": "mqtt in",
"z": "2b8c1d8a.6c28ba",
"name": "MQTT Node - TheThingsNetwork",
"topic": "#",
"qos": "2",
"broker": "19986064.b4bb7",
"x": 125,
"y": 110.5,
"wires": [
[
"cdb9ba77.4d97e8"
]
],
"outputLabels": [
"All"
]
},
{
"id": "a9e12de2.bd917",
"type": "influxdb out",
"z": "2b8c1d8a.6c28ba",
"influxdb": "6f9a1db.39f36e4",
"name": "",
"measurement": "",
"precision": "",
"retentionPolicy": "",
"x": 820,
"y": 540,
"wires": []
},
{
"id": "cdb9ba77.4d97e8",
"type": "json",
"z": "2b8c1d8a.6c28ba",
"name": "",
"pretty": false,
"x": 410,
"y": 40,
"wires": [
[
"d3f55ed7.091a38",
"8ba95514.f37f98"
]
]
},
{
"id": "d3f55ed7.091a38",
"type": "debug",
"z": "2b8c1d8a.6c28ba",
"name": "JSON",
"active": true,
"console": "false",
"complete": "payload",
"x": 710,
"y": 40,
"wires": []
},
{
"id": "b475105c.6ae458",
"type": "ui_gauge",
"z": "2b8c1d8a.6c28ba",
"name": "",
"group": "3c8dbb39.f8de0c",
"order": 0,
"width": 0,
"height": 0,
"gtype": "gage",
"title": "Temp",
"label": "Celsius",
"format": " {{value}}",
"min": "10",
"max": "30",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"seg1": "",
"seg2": "",
"x": 350,
"y": 300,
"wires": []
},
{
"id": "d66e52e8.b6bb38",
"type": "mqtt in",
"z": "2b8c1d8a.6c28ba",
"name": "Temperature",
"topic": "bme280sensortest/devices/loranode1/up/temperature_1",
"qos": "2",
"broker": "19986064.b4bb7",
"x": 90,
"y": 300,
"wires": [
[
"b475105c.6ae458",
"bd0f9007.7f5ac"
]
]
},
{
"id": "3008f035.eed17",
"type": "ui_gauge",
"z": "2b8c1d8a.6c28ba",
"name": "",
"group": "3c8dbb39.f8de0c",
"order": 0,
"width": 0,
"height": 0,
"gtype": "gage",
"title": "Barometric Pressure",
"label": "hPa",
"format": "{{value}}",
"min": "1000",
"max": "1100",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"seg1": "",
"seg2": "",
"x": 400,
"y": 360,
"wires": []
},
{
"id": "fe64850d.5cdcb8",
"type": "mqtt in",
"z": "2b8c1d8a.6c28ba",
"name": "Barometric Pressure",
"topic": "bme280sensortest/devices/loranode1/up/barometric_pressure_2",
"qos": "2",
"broker": "19986064.b4bb7",
"x": 110,
"y": 360,
"wires": [
[
"3008f035.eed17",
"9430440e.143fc"
]
]
},
{
"id": "b09d7d9c.86276",
"type": "ui_gauge",
"z": "2b8c1d8a.6c28ba",
"name": "",
"group": "3c8dbb39.f8de0c",
"order": 0,
"width": 0,
"height": 0,
"gtype": "gage",
"title": "Humidity",
"label": "Prozent",
"format": "{{value}}",
"min": 0,
"max": "100",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"seg1": "",
"seg2": "",
"x": 360,
"y": 420,
"wires": []
},
{
"id": "2a7e8e5c.4a4cba",
"type": "mqtt in",
"z": "2b8c1d8a.6c28ba",
"name": "Humidity",
"topic": "bme280sensortest/devices/loranode1/up/relative_humidity_3",
"qos": "2",
"broker": "19986064.b4bb7",
"x": 80,
"y": 420,
"wires": [
[
"b09d7d9c.86276",
"eb5f13b6.2b5168"
]
]
},
{
"id": "e08b401.a2da74",
"type": "ui_gauge",
"z": "2b8c1d8a.6c28ba",
"name": "",
"group": "3c8dbb39.f8de0c",
"order": 0,
"width": 0,
"height": 0,
"gtype": "gage",
"title": "Battery Level Sensor Node",
"label": "Volt",
"format": "{{value}}",
"min": "30",
"max": "40",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"seg1": "",
"seg2": "",
"x": 420,
"y": 480,
"wires": []
},
{
"id": "5f7abdf4.49e45c",
"type": "mqtt in",
"z": "2b8c1d8a.6c28ba",
"name": "Battery",
"topic": "bme280sensortest/devices/loranode1/up/analog_in_4",
"qos": "2",
"broker": "19986064.b4bb7",
"x": 70,
"y": 480,
"wires": [
[
"e08b401.a2da74",
"e8302b1d.abcf28"
]
]
},
{
"id": "bd0f9007.7f5ac",
"type": "delay",
"z": "2b8c1d8a.6c28ba",
"name": "Random delay",
"pauseType": "random",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "3",
"randomUnits": "seconds",
"drop": false,
"x": 380,
"y": 560,
"wires": [
[
"1d87c8da.2d9117"
]
]
},
{
"id": "1d87c8da.2d9117",
"type": "function",
"z": "2b8c1d8a.6c28ba",
"name": "Wait for all tasks to finish",
"func": "context.data = context.data || new Object();\n\nswitch (msg.topic) {\n case \"temperature_1\":\n context.data.task1 = msg.payload;\n msg = null;\n break;\n case \"barometric_pressure_2\":\n context.data.task2 = msg.payload;\n msg = null;\n break;\n case \"relative_humidity_3\":\n context.data.task3 = msg.payload;\n msg = null;\n break; \n case \"analog_in_4\":\n context.data.task4 = msg.payload;\n msg = null;\n break;\n \n default:\n msg = null;\n \tbreak;\n\n}\n\nif(context.data.task1 != null && context.data.task2 != null && context.data.task3 != null \n&& context.data.task4 != nul4 ) {\n\tmsg2 = new Object();\n msg2 = context.data;\n context.data=null;\n\treturn msg2;\n} else return msg;",
"outputs": 1,
"noerr": 0,
"x": 610,
"y": 620,
"wires": [
[
"a9e12de2.bd917",
"877f7489.4acbe8"
]
]
},
{
"id": "9430440e.143fc",
"type": "delay",
"z": "2b8c1d8a.6c28ba",
"name": "Random delay",
"pauseType": "random",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "3",
"randomUnits": "seconds",
"drop": false,
"x": 380,
"y": 600,
"wires": [
[
"1d87c8da.2d9117"
]
]
},
{
"id": "eb5f13b6.2b5168",
"type": "delay",
"z": "2b8c1d8a.6c28ba",
"name": "Random delay",
"pauseType": "random",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "3",
"randomUnits": "seconds",
"drop": false,
"x": 380,
"y": 640,
"wires": [
[
"1d87c8da.2d9117"
]
]
},
{
"id": "e8302b1d.abcf28",
"type": "delay",
"z": "2b8c1d8a.6c28ba",
"name": "Random delay",
"pauseType": "random",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "3",
"randomUnits": "seconds",
"drop": false,
"x": 380,
"y": 680,
"wires": [
[
"1d87c8da.2d9117"
]
]
},
{
"id": "877f7489.4acbe8",
"type": "debug",
"z": "2b8c1d8a.6c28ba",
"name": "JoinNodeTTN",
"active": true,
"console": "false",
"complete": "payload",
"x": 820,
"y": 700,
"wires": []
},
{
"id": "8ba95514.f37f98",
"type": "split",
"z": "2b8c1d8a.6c28ba",
"name": "",
"splt": ",",
"spltType": "str",
"arraySplt": "1",
"arraySpltType": "len",
"stream": false,
"addname": "",
"x": 410,
"y": 120,
"wires": [
[
"41241ae9.1233a4",
"d280b6ed.2aa728"
]
]
},
{
"id": "41241ae9.1233a4",
"type": "switch",
"z": "2b8c1d8a.6c28ba",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "cont",
"v": "\"analog_in_4\":",
"vt": "str"
},
{
"t": "cont",
"v": "\"barometric_pressure_2\":",
"vt": "str"
},
{
"t": "cont",
"v": "\"relative_humidity_3\":",
"vt": "str"
},
{
"t": "cont",
"v": "\"temperature_1\":",
"vt": "str"
}
],
"checkall": "true",
"outputs": 4,
"x": 550,
"y": 180,
"wires": [
[
"7e200176.f51448"
],
[
"ffd4c048.b102"
],
[
"7d1065f3.7272e4"
],
[
"b40ae61c.9809f8"
]
]
},
{
"id": "7e200176.f51448",
"type": "ui_gauge",
"z": "2b8c1d8a.6c28ba",
"name": "",
"group": "3c8dbb39.f8de0c",
"order": 0,
"width": 0,
"height": 0,
"gtype": "gage",
"title": "Analog",
"label": "units",
"format": "{{value}}",
"min": 0,
"max": 10,
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"seg1": "",
"seg2": "",
"x": 760,
"y": 160,
"wires": []
},
{
"id": "7d1065f3.7272e4",
"type": "ui_gauge",
"z": "2b8c1d8a.6c28ba",
"name": "",
"group": "3c8dbb39.f8de0c",
"order": 0,
"width": 0,
"height": 0,
"gtype": "gage",
"title": "Humidity",
"label": "units",
"format": "{{value}}",
"min": 0,
"max": 10,
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"seg1": "",
"seg2": "",
"x": 760,
"y": 240,
"wires": []
},
{
"id": "b40ae61c.9809f8",
"type": "ui_gauge",
"z": "2b8c1d8a.6c28ba",
"name": "",
"group": "3c8dbb39.f8de0c",
"order": 0,
"width": 0,
"height": 0,
"gtype": "gage",
"title": "Temperature",
"label": "units",
"format": "{{value}}",
"min": 0,
"max": 10,
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"seg1": "",
"seg2": "",
"x": 770,
"y": 280,
"wires": []
},
{
"id": "d280b6ed.2aa728",
"type": "debug",
"z": "2b8c1d8a.6c28ba",
"name": "Split",
"active": true,
"console": "false",
"complete": "payload",
"x": 670,
"y": 100,
"wires": []
},
{
"id": "ffd4c048.b102",
"type": "ui_gauge",
"z": "2b8c1d8a.6c28ba",
"name": "",
"group": "3c8dbb39.f8de0c",
"order": 0,
"width": 0,
"height": 0,
"gtype": "gage",
"title": "Pressure",
"label": "units",
"format": "{{value}}",
"min": 0,
"max": 10,
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"seg1": "",
"seg2": "",
"x": 760,
"y": 200,
"wires": []
},
{
"id": "19986064.b4bb7",
"type": "mqtt-broker",
"z": "2b8c1d8a.6c28ba",
"broker": "eu.thethings.network",
"port": "1883",
"clientid": "",
"usetls": false,
"verifyservercert": true,
"compatmode": true,
"keepalive": "60",
"cleansession": true,
"willTopic": "",
"willQos": "0",
"willRetain": null,
"willPayload": "",
"birthTopic": "",
"birthQos": "0",
"birthRetain": null,
"birthPayload": ""
},
{
"id": "6f9a1db.39f36e4",
"type": "influxdb",
"z": "",
"hostname": "192.168.178.126",
"port": "8086",
"protocol": "http",
"database": "ttndb",
"name": "",
"usetls": false,
"tls": ""
},
{
"id": "3c8dbb39.f8de0c",
"type": "ui_group",
"z": "",
"name": "Sensor Düsseldorf",
"tab": "234eafb3.3f6c7",
"order": 1,
"disp": true,
"width": "6"
},
{
"id": "234eafb3.3f6c7",
"type": "ui_tab",
"z": "",
"name": "Motes",
"icon": "dashboard",
"order": 1
}
]