Hallo, ich bin Walter und rel. neu in der Erstellung von Flow.
Bisher habe ich in C (Arduino) und Visual Basic for Applications programmiert.
Ich habe folgendes Problem:
In meinen Flow (Anhang) möchte ich Werte in eine Datei speichern, um diese später auswerten zu können.
Es funktioniert alles, bis auf die Abspeicherung in die Datei.
Den Dateinamen generiere ich aus den Datum. Wenn die Datei noch nicht existiert, wird diese erstellt. Bis dahin ist alles o.k.
Starte ich den Flow erneut, erhalte ich die Fehlermeldung, dass der Dateiname nicht im File Knoten eingetragen ist.
Es ist mir bisher nicht gelungen, die Eigenschaft <msg.filename> an den Fileknoten zu übergeben.
Wo liegt mein Fehler bzw. wie kann ich den Dateinamen an den File Knoten übergeben.
Vielen Dank für die Hilfe.
{English]
Hello, I'm Walter and rel. new to creating flow.
So far I've programmed in C (Arduino) and Visual Basic for Applications.
I have the following problem:
In my flow (attachment) I would like to save values in a file in order to be able to evaluate them later.
Everything works, except for the saving in the file.
I generate the file name from the date. If the file does not exist yet, it will be created. Until then everything is o.k.
If I start the flow again, I get the error message that the file name is not entered in the file node.
So far I have not been able to transfer the property <msg.filename> to the file node.
Where is my mistake or how can I transfer the file name to the file node.
Many thanks for the help.
Hier mein Flow:
[{"id":"bb0b1c9f.00da8","type":"tab","label":"Waschmaschine Strom sichern","disabled":false,"info":""},{"id":"700153c4.84c8ac","type":"mqtt in","z":"bb0b1c9f.00da8","name":"MQTT Broker lesen","topic":"stat/eg/waschmaschine/strom","qos":"0","datatype":"json","broker":"51dc6a63.563814","nl":false,"rap":false,"x":110,"y":80,"wires":[["f9553e6b.7cd5d","ae9d3e97.d7141","59b15b6c.959004"]]},{"id":"ae9d3e97.d7141","type":"function","z":"bb0b1c9f.00da8","name":"Wert - Strom","func":"wert= msg.payload.wert;\nmsg.payload= wert + ';' + 'mA';\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":350,"y":80,"wires":[["d53586ef.e26758"]]},{"id":"f9553e6b.7cd5d","type":"function","z":"bb0b1c9f.00da8","name":"Erstellung Datei","func":"msg.payload=\"\";\nfunction formatDate(date) {\n var d = new Date(date),\n month = '' + (d.getMonth() + 1),\n day = '' + d.getDate(),\n year = d.getFullYear();\n\n if (month.length < 2) month = '0' + month;\n if (day.length < 2) day = '0' + day;\n\n return [day, month, year].join('-');\n}\n\nvar tempString =formatDate(Date().toString());\n\nvar tempString1 = \"/media/pi/9A6D-72BD/Waschmaschine/\";\nvar tempString2 = tempString1.concat(tempString);\nvar finalPath = tempString2.concat(\".txt\");\nmsg.filename = finalPath;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":20,"wires":[["ad21bcd8.972b9"]]},{"id":"59b15b6c.959004","type":"function","z":"bb0b1c9f.00da8","name":"Zeit","func":"zeit= msg.payload.Zeit;\nmsg.payload= zeit;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":140,"wires":[["34ffbc57.225af4"]]},{"id":"34ffbc57.225af4","type":"function","z":"bb0b1c9f.00da8","name":"timestamp in HH:mm:ss","func":"var dt = new Date(msg.payload);\n\nvar Monat = dt.getMonth() + 1;\nvar Tag = dt.getDate();\nvar Jahr = dt.getFullYear();\nvar Stunde = dt.getHours();\nvar Minute = dt.getMinutes();\nvar Sekunde = dt.getSeconds();\n\nif(Monat.toString().length == 1) {\n var Monat = '0'+Monat;\n }\n \nif(Tag.toString().length == 1) {\n var Tag = '0'+Tag;\n }\n \n if(Stunde.toString().length == 1) {\n var Stunde = '0'+Stunde;\n }\n \n if(Minute.toString().length == 1) {\n var Minute = '0'+Minute;\n }\n\n if(Sekunde.toString().length == 1) {\n var Sekunde = '0'+Sekunde;\n }\n \nmsg.payload = Stunde + ':' + Minute;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":530,"y":140,"wires":[["d53586ef.e26758"]]},{"id":"d53586ef.e26758","type":"join","z":"bb0b1c9f.00da8","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":";","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":510,"y":80,"wires":[["ad21bcd8.972b9"]],"inputLabels":["2"],"outputLabels":["1"]},{"id":"ad21bcd8.972b9","type":"file","z":"bb0b1c9f.00da8","name":"","filename":"","appendNewline":false,"createDir":false,"overwriteFile":"false","encoding":"none","x":630,"y":20,"wires":[[]]},{"id":"f5dfc7e1.4838a8","type":"file function","z":"bb0b1c9f.00da8","name":"","filename":"","reloadfile":true,"outputs":1,"x":300,"y":540,"wires":[[]]},{"id":"51dc6a63.563814","type":"mqtt-broker","name":"","broker":"192.168.2.115","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"stat/eg/waschmaschine/strom","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]