Hello Jean,
I came up with this JS
let lines = msg.payload.split("\n")
node.warn(lines)
lines.forEach((line, index) => {
if (line.startsWith("auto_config_delay")) {
lines[index] = "auto_config_delay=" + msg.delay;
}
})
msg.payload = lines.join("\n")
return msg;
[EDIT] Or by using regular expressions
msg.payload = msg.payload.replace(/(auto_config_delay=)(\d+)/, `$1${msg.delay}` )
return msg;
Test flow (... change the path in the File read node)
[{"id":"cbd871c9b60dd253","type":"inject","z":"54efb553244c241f","name":"1000","props":[{"p":"payload"},{"p":"topic","vt":"str"},{"p":"delay","v":"1000","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":210,"y":780,"wires":[["3fe504116b9214f4"]]},{"id":"3fe504116b9214f4","type":"file in","z":"54efb553244c241f","name":"","filename":"c:\\users\\user\\desktop\\raspiwifi.conf","format":"utf8","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":480,"y":820,"wires":[["48d7e0382b2e1ae0","e4b016f58f37a2b4"]]},{"id":"10b68ecfef925297","type":"debug","z":"54efb553244c241f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":870,"y":780,"wires":[]},{"id":"58171be59591a3a9","type":"inject","z":"54efb553244c241f","name":"3000","props":[{"p":"payload"},{"p":"topic","vt":"str"},{"p":"delay","v":"3000","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":210,"y":880,"wires":[["3fe504116b9214f4"]]},{"id":"e4b016f58f37a2b4","type":"function","z":"54efb553244c241f","name":"forEach","func":"let lines = msg.payload.split(\"\\n\")\n//node.warn(lines)\n\nlines.forEach((line, index) => {\n if (line.startsWith(\"auto_config_delay\")) {\n lines[index] = \"auto_config_delay=\" + msg.delay;\n }\n})\n\nmsg.payload = lines.join(\"\\n\")\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":720,"y":780,"wires":[["10b68ecfef925297"]]},{"id":"a04535d87d3024f8","type":"debug","z":"54efb553244c241f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":870,"y":860,"wires":[]},{"id":"48d7e0382b2e1ae0","type":"function","z":"54efb553244c241f","name":"Regex","func":"msg.payload = msg.payload.replace(/(auto_config_delay=)(\\d+)/, `$1${msg.delay}` )\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":710,"y":860,"wires":[["a04535d87d3024f8"]]}]