Add a fictitious value to a payload or ignore a specific one

Unfortunately I am struggling with a flow and I have too little knowledge to solve this.

I retrieve data from The Things Network via MQTT, which is only one field with air pressure ("luchtdruk"). This value is written in an Influx Database, as a CSV-file on the Raspberry and that CSV-file is uploaded to a web server via FTP.

This all goes well in the end, but when the LoRa end node is switched on, the TTN join is first confirmed. This first payload contains all kinds of information, but of course not yet the air pressure. That value is only added to the second and subsequent transmission. This join confirmation will generate an error in the Edit Node:

No columns template specified for object -> CSV.

And in the Edit Influx Out Node:

Error: A 400 Bad Request error occurred: {"error": "unable to parse 'air pressure': missing fields"}

I would like to avoid this by ignoring the first payload (the join) or by giving that first payload a fictitious value for the air pressure fields so that field is not empty.

Can someone advise me how best to do this?

[{"id":"26063609.8a206a","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"ab3f9b08.66f8d8","type":"mqtt in","z":"26063609.8a206a","name":"TTN MQTT #","topic":"#","qos":"2","datatype":"json","broker":"47f2cc62.a875c4","nl":false,"rap":false,"x":130,"y":200,"wires":[["c7e5d2.29273a3","81257a18.b7fdd8"]]},{"id":"81257a18.b7fdd8","type":"change","z":"26063609.8a206a","name":"Change","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\t\"luchtdruk\": payload.uplink_message.decoded_payload.luchtdruk\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":160,"wires":[["fd7619ae.dc6508"]]},{"id":"fd7619ae.dc6508","type":"influxdb out","z":"26063609.8a206a","influxdb":"92192c23.a0c2c","name":"DB Luchtdruk","measurement":"luchtdruk","precision":"","retentionPolicy":"","database":"luchtdruk","retentionPolicyV18Flux":"","org":"","bucket":"","x":500,"y":160,"wires":[]},{"id":"2a728aad.193b86","type":"csv","z":"26063609.8a206a","name":"Build CSV","sep":",","hdrin":true,"hdrout":"none","multi":"one","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":false,"include_null_values":false,"x":490,"y":240,"wires":[["d0345784.739788"]]},{"id":"386731df.8f2b6e","type":"advanced-ftp","z":"26063609.8a206a","ftp":"d4690d47.9b012","operation":"put","dataType":"ascii","filename":"/public_html/wp-content/uploads/CSV/luchtdruk.csv","localFilename":"CSV/luchtdruk.csv","workingDir":"","oldPath":"","newPath":"","command":"","recursive":false,"useCompression":false,"throwError":false,"showError":true,"name":"FTP Luchtdruk","x":880,"y":240,"wires":[[]]},{"id":"d0345784.739788","type":"file","z":"26063609.8a206a","name":"Save RPi local","filename":"CSV/luchtdruk.csv","appendNewline":false,"createDir":false,"overwriteFile":"false","encoding":"none","x":680,"y":240,"wires":[["386731df.8f2b6e"]]},{"id":"c7e5d2.29273a3","type":"change","z":"26063609.8a206a","name":"Change","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\t\"tijd\":$now('[H01]:[m01]','0200'), \"luchtdruk\": payload.uplink_message.decoded_payload.luchtdruk\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":240,"wires":[["2a728aad.193b86"]]},{"id":"47f2cc62.a875c4","type":"mqtt-broker","name":"Luchtdruk","broker":"eu1.cloud.thethings.network","port":"1883","clientid":"","usetls":false,"compatmode":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""},{"id":"92192c23.a0c2c","type":"influxdb","hostname":"192.168.2.185","port":"8086","protocol":"http","database":"luchtdruk","name":"Luchtdruk","usetls":false,"tls":"1e7c3760.240cb9","influxdbVersion":"1.x","url":"192.168.2.185:8086","rejectUnauthorized":false},{"id":"d4690d47.9b012","type":"advanced-ftp-config","host":"ftp.xyz.nl","port":"","secure":false,"secureOptions":"","user":"hans@xyz.nl","connTimeout":"","pasvTimeout":"","keepalive":"","name":"FTP xyz.nl"},{"id":"1e7c3760.240cb9","type":"tls-config","name":"","cert":"","key":"","ca":"","certname":"","keyname":"","caname":"","servername":"","verifyservercert":true}]

Does this first payload have a different topic?

If so, then change your subscription topic or add a switch node to only allow the message to pass based on either the topic or content.

If you want more help, show us the contents of the first and subsequent incoming messages.

Thanks for helping! As far as I can see the topic is the same. You can find the incoming messages in the attachments, I hope that will help you. I saw no possibility to display them as text code, hence in a capture.

the topics are different...

image

image

so as i said, either ONLY subscripe to the ".../.../.../up" topic OR use a switch node to only permit messages that equal that topic to pass.

2 Likes

Thank you very much Steve, I chose the easiest option and subscribed to the ... / up topic and that works fine.

Unfortunately everyone now knows that I am a beginner, I have to learn to live with that :wink:

1 Like

Everyone starts at the beginning - glad it is solved.

By the time you have learnt to live with it you won't be a beginner, so you won't have to live with it.

Don't worry I get used to it :wink:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.