Hello everybody, I worked again at my nodes and InfluxDB. I got a good Example how to change data for wrinting it in Influx.
Like here:
[
{
"id": "c593b69ee7f352bd",
"type": "mqtt in",
"z": "f6f2187d.f17ca8",
"name": "Leistung AC [W]",
"topic": "Solaranlage/total/P_AC",
"qos": "0",
"datatype": "auto-detect",
"broker": "2dd28f61901aa014",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 100,
"y": 320,
"wires": [
[
"ca8cac0a5b8c8c1f",
"d4288cfb4ef11ee0"
]
]
},
{
"id": "d4288cfb4ef11ee0",
"type": "change",
"z": "f6f2187d.f17ca8",
"name": "",
"rules": [
{
"t": "move",
"p": "payload",
"pt": "msg",
"to": "msg.payload.P_AC",
"tot": "msg"
},
{
"t": "set",
"p": "msg.payload.Total P_AC",
"pt": "msg",
"to": "",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 390,
"y": 320,
"wires": [
[
"c32ca859d36df620",
"8916682ef237a5e6"
]
]
},
{
"id": "c32ca859d36df620",
"type": "influxdb out",
"z": "f6f2187d.f17ca8",
"influxdb": "b27ce1f4be5b0412",
"name": "P_AC_DB",
"measurement": "Total",
"precision": "",
"retentionPolicy": "",
"database": "database",
"precisionV18FluxV20": "s",
"retentionPolicyV18Flux": "",
"org": "Strom",
"bucket": "test5",
"x": 640,
"y": 320,
"wires": []
},
{
"id": "2dd28f61901aa014",
"type": "mqtt-broker",
"name": "MQTT Broker",
"broker": "192.168.178.245",
"port": "1886",
"clientid": "",
"autoConnect": true,
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willPayload": "",
"willMsg": {},
"userProps": "",
"sessionExpiry": ""
},
{
"id": "b27ce1f4be5b0412",
"type": "influxdb",
"hostname": "127.0.0.1",
"port": "8086",
"protocol": "http",
"database": "database",
"name": "Influx DB2",
"usetls": false,
"tls": "",
"influxdbVersion": "2.0",
"url": "http://192.168.178.245:8086",
"rejectUnauthorized": true
}
]
Now I try to write data from the MQTT Solar DTU to InfluxDB and want to add tags and fields for influxDB, to structure the data better.
Line Protocoll for InfluxDB to write data:
measurement,tagkey="tagvalue" fieldkey="fieldValue"
Example:
Inverters,Inverter=2.1_Süd U_AC=235
Or
Module,Modul=S.1.4 YieldDay=450
I used to try Change node again but I never get the data where I want to.
Here is my last try of the change node:
[
{
"id": "7b13402176c4286c",
"type": "mqtt in",
"z": "f6f2187d.f17ca8",
"name": "Spannung_AC [V]",
"topic": "Solaranlage/Inverter_2.1_Su/ch0/U_AC",
"qos": "0",
"datatype": "auto-detect",
"broker": "2dd28f61901aa014",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 550,
"y": 580,
"wires": [
[
"a97564372d02f196",
"a628c5a505e995d5",
"2385695c14db7090"
]
]
},
{
"id": "2385695c14db7090",
"type": "change",
"z": "f6f2187d.f17ca8",
"name": "",
"rules": [
{
"t": "set",
"p": "measurement",
"pt": "msg",
"to": "Inverters",
"tot": "str"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "Inverter=2.1_Süd,U_AC",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 790,
"y": 580,
"wires": [
[
"05722bc5b6ed4055",
"40a360ed0cfbc885"
]
]
},
{
"id": "05722bc5b6ed4055",
"type": "influxdb out",
"z": "f6f2187d.f17ca8",
"influxdb": "b27ce1f4be5b0412",
"name": "DB",
"measurement": "Inverters",
"precision": "",
"retentionPolicy": "",
"database": "database",
"precisionV18FluxV20": "s",
"retentionPolicyV18Flux": "",
"org": "Strom",
"bucket": "test5",
"x": 970,
"y": 580,
"wires": []
},
{
"id": "2dd28f61901aa014",
"type": "mqtt-broker",
"name": "MQTT Broker",
"broker": "192.168.178.245",
"port": "1886",
"clientid": "",
"autoConnect": true,
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willPayload": "",
"willMsg": {},
"userProps": "",
"sessionExpiry": ""
},
{
"id": "b27ce1f4be5b0412",
"type": "influxdb",
"hostname": "127.0.0.1",
"port": "8086",
"protocol": "http",
"database": "database",
"name": "Influx DB2",
"usetls": false,
"tls": "",
"influxdbVersion": "2.0",
"url": "http://192.168.178.245:8086",
"rejectUnauthorized": true
}
]
Honestly I thought I understand the change node, the msg.payload and the functions but it looks like I did not. Could somebody give me a hint where I am wrong?