Hello,
Short version: How can I use the msg.payload in the filename I want to read with the node 'Read File'?
Why:
I'm working on the following flow:
[{"id":"d944d9276f412dd6","type":"tab","label":"TESTFLOW","disabled":false,"info":"","env":[]},{"id":"156d68144591beb5","type":"inject","z":"d944d9276f412dd6","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":360,"wires":[["34076bdb35c18cf9"]]},{"id":"43370ce157a1dad4","type":"file in","z":"d944d9276f412dd6","name":"","filename":"/config/GamePC/\"global.CSV\"","format":"utf8","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":350,"y":160,"wires":[["8157078afc13d0ac"]]},{"id":"34076bdb35c18cf9","type":"fs-ops-dir","z":"d944d9276f412dd6","name":"Get files in .../GamePC","path":"/config/GamePC","pathType":"str","filter":"*","filterType":"str","dir":"files","dirType":"msg","x":360,"y":360,"wires":[["2eaf1e780dfee6bf"]]},{"id":"e3ace22bd689d0fe","type":"api-call-service","z":"d944d9276f412dd6","name":"Delete logfiles iCue","server":"acb16d44.e70d3","version":3,"debugenabled":false,"service_domain":"delete","service":"files_in_folder","entityId":"","data":"{\"folder\":\"/config/GamePC\",\"time\":10}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":410,"y":460,"wires":[[]]},{"id":"0814cdd3f53c18ad","type":"inject","z":"d944d9276f412dd6","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":460,"wires":[["e3ace22bd689d0fe"]]},{"id":"b09d95adae19c0db","type":"inject","z":"d944d9276f412dd6","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":160,"wires":[["43370ce157a1dad4"]]},{"id":"8157078afc13d0ac","type":"csv","z":"d944d9276f412dd6","name":"","sep":",","hdrin":true,"hdrout":"none","multi":"mult","ret":"\\n","temp":"Timestamp,\"CPU Package\",\"CPU Load\",\"GPU Temp #2\",\"COMMANDER PRO Exhaust\",\"COMMANDER PRO Watertemp\",\"COMMANDER PRO Intake\"","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":710,"y":160,"wires":[["03b59a09d0cc6375"]]},{"id":"03b59a09d0cc6375","type":"function","z":"d944d9276f412dd6","name":"","func":"var my_array = msg.payload;\nvar last_element = my_array[my_array.length - 1];\nmsg.payload = last_element;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":840,"y":160,"wires":[["7510406112651b96","482a10aa120491ba","bc4fbbe85b7d555d","b1bea7dee428b271","d55437617dfcc60d","c2a19ad0e837bcf6"]]},{"id":"2eaf1e780dfee6bf","type":"function","z":"d944d9276f412dd6","name":"Laatste .csv","func":"var my_array = msg.files;\nvar last_element = my_array[my_array.length - 1];\nmsg.payload = last_element;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":590,"y":360,"wires":[["3d194345a3b09ae6"]]},{"id":"7510406112651b96","type":"ha-entity","z":"d944d9276f412dd6","name":"GamePC CPU Temp","server":"acb16d44.e70d3","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":""},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"payload[\"CPU Package\"]","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1060,"y":60,"wires":[[]]},{"id":"482a10aa120491ba","type":"ha-entity","z":"d944d9276f412dd6","name":"GamePC CPU Load","server":"acb16d44.e70d3","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":""},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"payload[\"CPU Load\"]","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1060,"y":120,"wires":[[]]},{"id":"bc4fbbe85b7d555d","type":"ha-entity","z":"d944d9276f412dd6","name":"GamePC GPU Temp","server":"acb16d44.e70d3","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":""},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"payload[\"GPU Temp #2\"]","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1060,"y":180,"wires":[[]]},{"id":"b1bea7dee428b271","type":"ha-entity","z":"d944d9276f412dd6","name":"GamePC Exhaust Temp","server":"acb16d44.e70d3","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":""},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"payload[\"COMMANDER PRO Exhaust\"]","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1070,"y":240,"wires":[[]]},{"id":"d55437617dfcc60d","type":"ha-entity","z":"d944d9276f412dd6","name":"GamePC Water Temp","server":"acb16d44.e70d3","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":""},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"payload[\"COMMANDER PRO Watertemp\"]","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1060,"y":300,"wires":[[]]},{"id":"c2a19ad0e837bcf6","type":"ha-entity","z":"d944d9276f412dd6","name":"GamePC Intake Temp","server":"acb16d44.e70d3","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":""},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"payload[\"COMMANDER PRO Intake\"]","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1060,"y":360,"wires":[[]]},{"id":"3d194345a3b09ae6","type":"change","z":"d944d9276f412dd6","name":"CSV Global","rules":[{"t":"set","p":"CSV","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":360,"wires":[[]]},{"id":"acb16d44.e70d3","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]
I have a folder were a different PC creates a .csv logfile. When the PC reboots, it creates a new file, so I'm automating the pick and read of the newest file. Everything is working, accept for the transfer of the filename from the context global.CSV to the filename after the path.
Anyone knows how to get this done?
Thanks,
Seyude