Hi micha53 and welcome to the forum.
It looks to me like you are over complicating the process.
To help you, you will need to provide some things.
1 the output of all your mqtt nodes.
There’s a great page in the docs (Working with messages : Node-RED) that will explain how to use the debug panel to find the right path/value for any data item.
Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.
In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote ```
)
```
code goes here
```
See this post for more details - How to share code or flow json
2 How you would like the csv to look . Pointing out which bits of data go where, using your provided mqtt outputs in this example.
I am sure we can then get rid of most of the join and change nodes and use a csv node to construct the csv output.
[edit] here is a simplified version of what you possibly could do. It will add a new csv line everytime the status comes back online. Hope this helps you see another way.
[{"id":"9180d579ee033784","type":"inject","z":"667cec54c048503c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"wican/7c2c67b3dbc1/can/status","payload":"{\"status\":\"online\"}","payloadType":"json","x":140,"y":240,"wires":[["89579474bdcc9cc4"]]},{"id":"89579474bdcc9cc4","type":"change","z":"667cec54c048503c","name":"","rules":[{"t":"set","p":"payload.timestamp","pt":"msg","to":"iso","tot":"date"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":280,"wires":[["7632ca7698b33e53"]]},{"id":"836d95041d6212ac","type":"inject","z":"667cec54c048503c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"wican/7c2c67b3dbc1/can/status","payload":"{\"status\":\"offline\"}","payloadType":"json","x":140,"y":280,"wires":[["89579474bdcc9cc4"]]},{"id":"7632ca7698b33e53","type":"join","z":"667cec54c048503c","name":"","mode":"custom","build":"merged","property":"payload","propertyType":"msg","key":"topic","joiner":";","joinerType":"str","useparts":false,"accumulate":true,"timeout":"","count":"6","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":450,"y":360,"wires":[["c10fc05243b85321"]]},{"id":"6ad58402458bfd9a","type":"inject","z":"667cec54c048503c","name":"cfos_mqtt/get/E1","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"cfos_mqtt/get/E1","payload":"{\"total_energy\":20.9,\"used_phases\":3}","payloadType":"json","x":140,"y":360,"wires":[["7632ca7698b33e53"]]},{"id":"7979fda9689fa078","type":"inject","z":"667cec54c048503c","name":"cfos_mqtt/get/E1","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"wican/7c2c67b3dbc1/auto","payload":"{\"oddometer\":2.6,\"soc\":10}","payloadType":"json","x":140,"y":460,"wires":[["7632ca7698b33e53"]]},{"id":"c10fc05243b85321","type":"rbe","z":"667cec54c048503c","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload.status","topi":"topic","x":570,"y":360,"wires":[["8ef5b1d932e947dd"]]},{"id":"8ef5b1d932e947dd","type":"switch","z":"667cec54c048503c","name":"","property":"payload.status","propertyType":"msg","rules":[{"t":"eq","v":"online","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":690,"y":360,"wires":[["3239c497b3c37ccb"]]},{"id":"3239c497b3c37ccb","type":"csv","z":"667cec54c048503c","name":"","spec":"rfc","sep":";","hdrin":"","hdrout":"none","multi":"one","ret":"\\n","temp":"timestamp,total_energy,soc,used_phases,oddometer,status","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":810,"y":360,"wires":[["ac0464631b5580fe"]]},{"id":"ac0464631b5580fe","type":"debug","z":"667cec54c048503c","name":"debug 4","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":820,"y":160,"wires":[]},{"id":"87b8aed1b7e49c7c","type":"file","z":"667cec54c048503c","name":"Zoe-Daten.csv","filename":"\\\\fritz.box\\AremoricaNAS\\backup\\micha\\Dokumente\\NodeRed\\Zoe-Daten.csv","filenameType":"str","appendNewline":false,"createDir":false,"overwriteFile":"false","encoding":"utf8","x":900,"y":300,"wires":[[]]}]
Or splitting the incoming objects, which allows you to manipulate each payload.
[{"id":"9180d579ee033784","type":"inject","z":"667cec54c048503c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"wican/7c2c67b3dbc1/can/status","payload":"{\"status\":\"online\"}","payloadType":"json","x":140,"y":240,"wires":[["89579474bdcc9cc4"]]},{"id":"89579474bdcc9cc4","type":"change","z":"667cec54c048503c","name":"","rules":[{"t":"set","p":"payload.timestamp","pt":"msg","to":"iso","tot":"date"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":260,"wires":[["11c1b2d8775266f7"]]},{"id":"836d95041d6212ac","type":"inject","z":"667cec54c048503c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"wican/7c2c67b3dbc1/can/status","payload":"{\"status\":\"offline\"}","payloadType":"json","x":140,"y":280,"wires":[["89579474bdcc9cc4"]]},{"id":"11c1b2d8775266f7","type":"split","z":"667cec54c048503c","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"key","property":"payload","x":330,"y":360,"wires":[["48bd2347f98ade8c"]]},{"id":"6ad58402458bfd9a","type":"inject","z":"667cec54c048503c","name":"cfos_mqtt/get/E1","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"cfos_mqtt/get/E1","payload":"{\"total_energy\":20.9,\"used_phases\":3}","payloadType":"json","x":140,"y":360,"wires":[["11c1b2d8775266f7"]]},{"id":"7979fda9689fa078","type":"inject","z":"667cec54c048503c","name":"cfos_mqtt/get/E1","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"wican/7c2c67b3dbc1/auto","payload":"{\"oddometer\":2.6,\"soc\":10}","payloadType":"json","x":140,"y":460,"wires":[["11c1b2d8775266f7"]]},{"id":"48bd2347f98ade8c","type":"template","z":"667cec54c048503c","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload}}","output":"str","x":480,"y":360,"wires":[["b5dfadf7f077b97a"]]},{"id":"b5dfadf7f077b97a","type":"change","z":"667cec54c048503c","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":".","fromt":"str","to":",","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":360,"wires":[["17b03cc909c256a2"]]},{"id":"17b03cc909c256a2","type":"join","z":"667cec54c048503c","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"key","joiner":"\\n","joinerType":"str","useparts":false,"accumulate":true,"timeout":"","count":"6","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":410,"y":480,"wires":[["c10fc05243b85321"]]},{"id":"c10fc05243b85321","type":"rbe","z":"667cec54c048503c","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload.status","topi":"topic","x":550,"y":480,"wires":[["8ef5b1d932e947dd"]]},{"id":"8ef5b1d932e947dd","type":"switch","z":"667cec54c048503c","name":"","property":"payload.status","propertyType":"msg","rules":[{"t":"eq","v":"online","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":690,"y":480,"wires":[["3239c497b3c37ccb"]]},{"id":"3239c497b3c37ccb","type":"csv","z":"667cec54c048503c","name":"","spec":"rfc","sep":";","hdrin":"","hdrout":"none","multi":"one","ret":"\\n","temp":"timestamp,total_energy,soc,used_phases,oddometer,status","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":810,"y":480,"wires":[["ac0464631b5580fe"]]},{"id":"ac0464631b5580fe","type":"debug","z":"667cec54c048503c","name":"debug 4","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":820,"y":160,"wires":[]},{"id":"87b8aed1b7e49c7c","type":"file","z":"667cec54c048503c","name":"Zoe-Daten.csv","filename":"\\\\fritz.box\\AremoricaNAS\\backup\\micha\\Dokumente\\NodeRed\\Zoe-Daten.csv","filenameType":"str","appendNewline":false,"createDir":false,"overwriteFile":"false","encoding":"utf8","x":900,"y":300,"wires":[[]]}]
The inject nodes simulate your mqtt in nodes.
I also suggest you store your timestamp as a UTC timestamp. You can more easily convert this to any timezone when you read the csv. You could also add a local time to the csv, but UTC is preferred for easy manipulation later.
The filter node will only pass the data when msg.payload.status changes.