This flow will find all your WLED entity IP’s. Request and save their presets.json
and cfg.json
files. Files will be stored in /media
. It will create a wled
folder and save each file in the format [IP address]_presets/cfg.json
.
There is a 5 second delay in between each request. The inject node can be set to repeat from daily to once a week depending on how often you want to perform a save.
[{"id":"bd0f1329afce8a6f","type":"function","z":"60f2d2277843c698","name":"Create requests","func":"let array = msg.payload;\nlet servers = [];\n\nfor (let i = 0; i < array.length; i++) {\n const element = array[i].state;\n servers.push(element);\n \n}\n\nlet i = 0;\nlet x = 0;\nvar delay = 0;\n\nfunction getPresetConfig() { \n setTimeout(function () { \n if (i < servers.length) {\n let serverAddress = servers[i];\n msg.url = \"http://\" + serverAddress + \"/edit?download=/presets.json\";\n node.send(msg);\n node.status({fill:\"green\",shape:\"dot\",text: \"preset req \" + serverAddress});\n delay = 5000;\n i++;\n getPresetConfig(); \n }\n else if (i >= servers.length && i < servers.length*2) {\n let serverAddress = servers[x];\n msg.url = \"http://\" + serverAddress + \"/edit?download=/cfg.json\";\n node.send(msg);\n node.status({ fill: \"green\", shape: \"dot\", text: \"config req \" + serverAddress })\n i++;\n x++;\n getPresetConfig()\n }\n else { \n node.status({ fill: \"green\", shape: \"dot\", text: \"done\" })\n node.done\n } \n }, delay)\n}\n\ngetPresetConfig(); ","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":500,"y":2400,"wires":[["33cf93ceab254df8"]]},{"id":"33cf93ceab254df8","type":"http request","z":"60f2d2277843c698","name":"Get presets/cfg","method":"GET","ret":"txt","paytoqs":"body","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":680,"y":2400,"wires":[["7f620c6753ac37bf"]]},{"id":"259f11805de467e3","type":"file","z":"60f2d2277843c698","name":"Save preset/config","filename":"filename","filenameType":"msg","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":1030,"y":2400,"wires":[[]]},{"id":"7f620c6753ac37bf","type":"change","z":"60f2d2277843c698","name":"format save","rules":[{"t":"delete","p":"topic","pt":"msg"},{"t":"delete","p":"statusCode","pt":"msg"},{"t":"delete","p":"headers","pt":"msg"},{"t":"delete","p":"responseUrl","pt":"msg"},{"t":"delete","p":"retry","pt":"msg"},{"t":"delete","p":"redirectList","pt":"msg"},{"t":"delete","p":"_msgid","pt":"msg"},{"t":"change","p":"url","pt":"msg","from":"http://","fromt":"str","to":"/media/wled/","tot":"str"},{"t":"change","p":"url","pt":"msg","from":"/edit?download=/","fromt":"str","to":"_","tot":"str"},{"t":"move","p":"url","pt":"msg","to":"filename","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":850,"y":2400,"wires":[["259f11805de467e3"]]},{"id":"58f13a729663b7cd","type":"ha-get-entities","z":"60f2d2277843c698","name":"Get wled IPs","server":"6b1110b5.183a4","version":1,"rules":[{"property":"attributes.friendly_name","logic":"is","value":"WLED","valueType":"re"},{"property":"attributes.friendly_name","logic":"is","value":"IP","valueType":"re"}],"outputType":"array","outputEmptyResults":false,"outputLocationType":"msg","outputLocation":"payload","outputResultsCount":1,"x":310,"y":2400,"wires":[["bd0f1329afce8a6f"]]},{"id":"bf268b76e2c6d10d","type":"inject","z":"60f2d2277843c698","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":2400,"wires":[["58f13a729663b7cd"]]},{"id":"6b1110b5.183a4","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":false,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]