Du schreibst den Inhalt Deiner function 18 in einer Flowvariable und die cronnode holt diese dann ab:
Deine function 18 - speicher die payload in einer Flow variablen - z.Bsp SML
dann machst den Ausgang Deiner function Node einfach weg:
82f5937f-191c-4919-90ad-9ed5fa1e6af2-image.png
Deine payload speicherst Du in einer Flow variable:
msg.payload = {
"SML.Total.in" : 5000,
"SML.Total.out": 15000,
"SML.Power_curren": 500,
"Time" : new Date()
}
flow.set ("SML", msg.payload);
Die function Node selbst gibt nichts mehr aus!!! (Also return msg; als letzte Zeile kannst wegschmeissen und die Ausgänge der function Node auf 0 stellen).
EDIT: Kannst natürlich auch den Ausgang dran lassen, um zu Debug Zwecken irgendwas mit einer Debug Node zu kontrollieren!! Wichtig ist ja nur die Speicherung im Flow-Kontext.
In Deinem Kontext sind aber die Inhalt gespeichert und werden aktualisiert.
2e4d010f-a24a-43a2-afb1-c9060808ad80-image.png
Die cron-plus Node holt nun den Inhalt der Flowvariablen ab und Du schreibst in die csv:
5b3a7a29-b73c-4ead-8c32-eff460baf7e7-image.png
Hier der Beispielflow zum Import:
Spoiler
[
{
"id": "5d827132f180d9ea",
"type": "function",
"z": "00b2bb10c6f72961",
"name": "function 18",
"func": "msg.payload = {\n \"SML.Total.in\" : 5000,\n \"SML.Total.out\": 15000,\n \"SML.Power_curren\": 500,\n\n \"Time\" : new Date()\n}\n\nflow.set (\"SML\", msg.payload);\n// return msg;",
"outputs": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 390,
"y": 500,
"wires": []
},
{
"id": "2245ac4b3ce16c32",
"type": "inject",
"z": "00b2bb10c6f72961",
"name": "trigger",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 190,
"y": 500,
"wires": [
[
"5d827132f180d9ea"
]
]
},
{
"id": "73eb8037e9423096",
"type": "cronplus",
"z": "00b2bb10c6f72961",
"name": "",
"outputField": "payload",
"timeZone": "",
"persistDynamic": false,
"commandResponseMsgOutput": "output1",
"outputs": 1,
"options": [
{
"name": "SML",
"topic": "monthlySML",
"payloadType": "flow",
"payload": "SML",
"expressionType": "cron",
"expression": "0 0 0 1 * * *",
"location": "",
"offset": "0",
"solarType": "all",
"solarEvents": "sunrise,sunset"
}
],
"x": 420,
"y": 560,
"wires": [
[
"2698d7c79fc129a6",
"c5e7d602db5a4f04"
]
]
},
{
"id": "66e2ea42728c843c",
"type": "inject",
"z": "00b2bb10c6f72961",
"name": "manueller Trigger",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "trigger",
"payload": "SML",
"payloadType": "str",
"x": 200,
"y": 560,
"wires": [
[
"73eb8037e9423096"
]
]
},
{
"id": "2698d7c79fc129a6",
"type": "debug",
"z": "00b2bb10c6f72961",
"name": "SML zur CSV Node",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 630,
"y": 540,
"wires": []
},
{
"id": "c5e7d602db5a4f04",
"type": "file",
"z": "00b2bb10c6f72961",
"d": true,
"name": "",
"filename": "test.csv",
"filenameType": "str",
"appendNewline": true,
"createDir": false,
"overwriteFile": "false",
"encoding": "none",
"x": 620,
"y": 600,
"wires": [
[]
]
}
]
=============================================================================================
Du musst halt dafür Sorge tragen, dass zum Zeitpunkt halt was korrektes im Flowkontext drin steht.