Hi all,
I'm totally new to nodered. I watched some videos and red some documentation but now it's time to get practial.
My "Idea": I have a Webapi on a device where I can get data in Json format:
{
"UniqueId":"Meter#1",
"Timestamp":"2019-02-15T22:33:09.622867513+01:00",
"Unix":1550266389,
"ModbusDeviceId":1,
"Power":{
"L1":0,
"L2":58.04953384399414,
"L3":7.187046051025391
},
"Voltage":{
"L1":235.2692108154297,
"L2":234.9277801513672,
"L3":233.99427795410156
},
"Current":{
"L1":0.06178390234708786,
"L2":0.46165990829467773,
"L3":0.08737564086914062
},
"Cosphi":{
"L1":0.12718620896339417,
"L2":0.5964568853378296,
"L3":0.33428090810775757
},
"Import":{
"L1":26.285999298095703,
"L2":43.43699645996094,
"L3":40.39099884033203
},
"TotalImport":110.11399841308594,
"Export":{
"L1":0,
"L2":0,
"L3":0.0009999999310821295
},
"TotalExport":0.0009999999310821295,
"THD":{
"VoltageNeutral":{
"L1":3.460484504699707,
"L2":3.1392886638641357,
"L3":3.341616153717041
},
"AvgVoltageNeutral":3.322300434112549
},
"Frequency":49.960819244384766
}
This Json shall be written to a mysql database.
To provide a feeling for my data: The Json-Data is from an electrical power meter; accessed via Modbus. This data shall be written into my mysql database to be presented in "volkszaehler" GUI.
At the moment I'm a stuck at the point where to prepare the data from the json api.
I downloaded the flow "contrib-json" to access all single pathes in the JSON but this cannot be the solution. Does somebody of you know a flow which can access all values of a json in an array or something like that? I expect, having it all separated, will lead to a challenge on inserting them into the database.
My current status:
[
{
"id": "f493ad5d.f5649",
"type": "tab",
"label": "Flow 4",
"disabled": false,
"info": ""
},
{
"id": "943726f5.867c68",
"type": "debug",
"z": "f493ad5d.f5649",
"name": "",
"active": false,
"tosidebar": true,
"console": true,
"tostatus": true,
"complete": "payload",
"x": 530,
"y": 297,
"wires": []
},
{
"id": "f5b6def7.5a7d4",
"type": "http request",
"z": "f493ad5d.f5649",
"name": "",
"method": "GET",
"ret": "txt",
"url": "http://192.168.178.90:8080/last/1",
"tls": "",
"x": 292.5,
"y": 280,
"wires": [
[
"943726f5.867c68",
"8824b733.35f7d8"
]
]
},
{
"id": "e4cd6f0a.b4827",
"type": "inject",
"z": "f493ad5d.f5649",
"name": "",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "",
"crontab": "",
"once": true,
"onceDelay": "0.5",
"x": 104,
"y": 279,
"wires": [
[
"f5b6def7.5a7d4"
]
]
},
{
"id": "8824b733.35f7d8",
"type": "json",
"z": "f493ad5d.f5649",
"name": "",
"property": "payload",
"action": "obj",
"pretty": false,
"x": 489.5,
"y": 390,
"wires": [
[
"2ce6ca80.f16306",
"a35db477.ed44e8",
"d3ca88cb.376278",
"607ff54d.ef5f8c",
"fc55729f.c4584",
"d99a608b.87b88",
"3371022e.4894ce"
]
]
},
{
"id": "2ce6ca80.f16306",
"type": "debug",
"z": "f493ad5d.f5649",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"x": 719.5,
"y": 405,
"wires": []
},
{
"id": "a35db477.ed44e8",
"type": "contrib-json",
"z": "f493ad5d.f5649",
"engine": "JSONPath",
"command": "jq",
"expr": "$.UniqueId",
"complete": "property",
"prop": "payload",
"name": "",
"x": 575.5,
"y": 593,
"wires": [
[
"1512f11b.4c817f"
]
]
},
{
"id": "1512f11b.4c817f",
"type": "debug",
"z": "f493ad5d.f5649",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"x": 765.5,
"y": 583,
"wires": []
},
{
"id": "d3ca88cb.376278",
"type": "contrib-json",
"z": "f493ad5d.f5649",
"engine": "JSONPath",
"command": "jq",
"expr": "$.Timestamp",
"complete": "property",
"prop": "payload",
"name": "",
"x": 575.5,
"y": 631,
"wires": [
[
"1512f11b.4c817f"
]
]
},
{
"id": "607ff54d.ef5f8c",
"type": "contrib-json",
"z": "f493ad5d.f5649",
"engine": "JSONPath",
"command": "jq",
"expr": "$.Unix",
"complete": "property",
"prop": "payload",
"name": "",
"x": 558.5,
"y": 675,
"wires": [
[
"1512f11b.4c817f"
]
]
},
{
"id": "fc55729f.c4584",
"type": "contrib-json",
"z": "f493ad5d.f5649",
"engine": "JSONPath",
"command": "jq",
"expr": "$.ModbusDeviceId",
"complete": "property",
"prop": "payload",
"name": "",
"x": 567.5,
"y": 722,
"wires": [
[
"1512f11b.4c817f"
]
]
},
{
"id": "d99a608b.87b88",
"type": "contrib-json",
"z": "f493ad5d.f5649",
"engine": "JSONPath",
"command": "jq",
"expr": "$.Power",
"complete": "property",
"prop": "payload",
"name": "",
"x": 567.5,
"y": 785,
"wires": [
[
"1512f11b.4c817f"
]
]
},
{
"id": "3371022e.4894ce",
"type": "contrib-json",
"z": "f493ad5d.f5649",
"engine": "JSONPath",
"command": "jq",
"expr": "$.Power.L1",
"complete": "property",
"prop": "payload",
"name": "",
"x": 567.5,
"y": 830,
"wires": [
[
"1512f11b.4c817f"
]
]
}
]
Thx and KR
Itchy2