so i have 1 automation that i testing with a pumpkin head i have LED
so i have a preset… and when the automation runs it saves the preset and the state if its on or off… runs for 20 seconds running a different preset… and then restores the previous state whatever that previous preset… and if its on or off… as its easier to do preset then the limited options in the wled node…
problem is its ok for 1… but i cant seem to figure out how to make it work for say 20 wleds to save each preset then restore the previous preset…
now i also noticed if i duplicate my automation to do just do 2 different ones… because i guess i have msg.preset for both automations it buggers things up… i guess the preset is global in the flow
now back in 90s when i programmed in gwbasic etc i used dim shares to save multiple settings… and i guess you might use that function node now a days…
but i have no idea… i though putting all the wled’s in 1 group for preset, and online state but that didnt work
what would be the easiest so your not multiplying the automation 100 times as this specific automation is for when an incomming call comes in i want it to set all the 20 say wleds to “incoming call” preset like i already have… and then after 20 seconds it restores the previous state for all 20 wleds…
for now i only can do 1…
here is my code
[{"id":"e934eb2147ee44c0","type":"link in","z":"b511d8822e5a6efc","name":"LED Strips In","links":["4b56e51bf617e996"],"x":65,"y":640,"wires":[["11179c754de12c35","b474bf4c7827cc40"]]},{"id":"3982ce50fa4a96ad","type":"api-call-service","z":"b511d8822e5a6efc","name":"Wled - Incoming Call","server":"915baa48.9b1898","version":7,"debugenabled":false,"action":"select.select_option","floorId":[],"areaId":[],"deviceId":[],"entityId":["select.pumpkin_head_1_preset"],"labelId":[],"data":"{\t \"option\": \"Incoming Call\"\t\t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","blockInputOverrides":true,"domain":"select","service":"select_option","x":450,"y":640,"wires":[["ac80364ff12b5cd2"]]},{"id":"11179c754de12c35","type":"api-current-state","z":"b511d8822e5a6efc","name":"Light current state","server":"915baa48.9b1898","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"light.pumpkin_head_1","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"light_data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":220,"y":620,"wires":[["3982ce50fa4a96ad","15a7e824e1049a28"]]},{"id":"264c3a4121991d4e","type":"inject","z":"b511d8822e5a6efc","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":90,"y":780,"wires":[["11179c754de12c35","b474bf4c7827cc40"]]},{"id":"d76e8f95bb91fdec","type":"switch","z":"b511d8822e5a6efc","name":"previously on or off?","property":"light_data.state","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":450,"y":800,"wires":[["56ed747605874a61"],["c06fdc411f0b89aa"]]},{"id":"ac80364ff12b5cd2","type":"delay","z":"b511d8822e5a6efc","name":"","pauseType":"delay","timeout":"20","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":410,"y":700,"wires":[["5dea7a3f185b67af"]]},{"id":"5dea7a3f185b67af","type":"change","z":"b511d8822e5a6efc","name":"switch flow. back to msg.","rules":[{"t":"set","p":"palette","pt":"msg","to":"palette","tot":"flow"},{"t":"set","p":"light_data","pt":"msg","to":"light_data","tot":"flow"},{"t":"set","p":"preset","pt":"msg","to":"preset","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":760,"wires":[["d76e8f95bb91fdec"]]},{"id":"b474bf4c7827cc40","type":"api-current-state","z":"b511d8822e5a6efc","name":"Light Preset","server":"915baa48.9b1898","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"select.pumpkin_head_1_preset","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"preset","propertyType":"msg","value":"","valueType":"entityState"}],"for":0,"forType":"num","forUnits":"minutes","x":220,"y":680,"wires":[["3982ce50fa4a96ad","0ee60871fc9b3929"]]},{"id":"0ee60871fc9b3929","type":"change","z":"b511d8822e5a6efc","name":"save preset to flow.","rules":[{"t":"set","p":"preset","pt":"flow","to":"preset","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":540,"wires":[[]]},{"id":"15a7e824e1049a28","type":"change","z":"b511d8822e5a6efc","name":"save light data to flow.","rules":[{"t":"set","p":"light_data","pt":"flow","to":"light_data","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":580,"wires":[[]]},{"id":"56ed747605874a61","type":"api-call-service","z":"b511d8822e5a6efc","name":"Previous Preset","server":"915baa48.9b1898","version":7,"debugenabled":false,"action":"select.select_option","floorId":[],"areaId":[],"deviceId":[],"entityId":["select.pumpkin_head_1_preset"],"labelId":[],"data":"{\t \"option\": msg.preset\t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","blockInputOverrides":false,"domain":"select","service":"select_option","output_location":"","output_location_type":"none","x":740,"y":780,"wires":[["4e02023ab606d8e2"]]},{"id":"077885883d099ff1","type":"comment","z":"b511d8822e5a6efc","name":"Incoming Calls Notification LED Pumpkin","info":"","x":160,"y":500,"wires":[]},{"id":"c06fdc411f0b89aa","type":"api-call-service","z":"b511d8822e5a6efc","name":"Turn Off Lights","server":"915baa48.9b1898","version":7,"debugenabled":false,"action":"light.turn_off","floorId":[],"areaId":[],"deviceId":[],"entityId":["light.pumpkin_head_1"],"labelId":[],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","blockInputOverrides":false,"domain":"light","service":"turn_off","output_location":"","output_location_type":"none","x":740,"y":840,"wires":[[]]},{"id":"4e02023ab606d8e2","type":"debug","z":"b511d8822e5a6efc","name":"debug 29","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"preset","targetType":"msg","statusVal":"","statusType":"auto","x":900,"y":720,"wires":[]},{"id":"915baa48.9b1898","type":"server","name":"Home Assistant","version":6,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":["y","yes","true","on","home","open"],"connectionDelay":true,"cacheJson":true,"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},{"id":"f577c238b6e1b4de","type":"global-config","env":[],"modules":{"node-red-contrib-home-assistant-websocket":"0.80.1"}}]
im hoping there is a simple like
array(x)=x+1 and it just does like
preset(x) onoff_state(x)
so it would count the number of wleds in the group say and then
be like
(pumpkin)wled name, chase2 preset, on state
(happy_halloween)wled name , off state
(bedroom_strip)wled name, chase 3 preset, on state
(rack_strip)wled name, twinkles preset, on state
so then when automation runs
(pumpkin)wled name, incoming call preset, on state
(happy_halloween)wled name , incoming call preset,on state
(bedroom_strip)wled name, incoming call preset, on state
(rack_strip)wled name, incoming callpreset, on state
then when 20 seconds is done restore all the presets and on off state to previous without having to duplicate the same automation 4 times in this example and times more for any other event… id like 1 automation to do all in a group style so i can just edit the yaml to add more wleds etc
so then be like
preset(1), onoff_state(1)
preset(2), onoff_state(2)
in a like do loop
do
x=x+1
loop while x< (number of wleds in group)
sorry if i confusing i have dyselxia and in my head i explaing things right… so i hope i explain it ok


