Help creating loop x times with turn on and off Entity component

Hi,

Long story, I have a swimming pool pump that randomly stops working when turned on. To get around this I have been using node-red to start the pump (wifi switch) run for 30mins, stop for 5mins then repeat 8 times so the pump runs for approx. 4 hours in total. What I have works but is very clumsy. My reason for posing is my wifi switch just died and I needed to replace it, this results in needing to edit each on-off with the new entity id.

Any ideas how to make this easier where I can set the number of loops and time period the on and off periods should be? I did try looptimer but couldn’t work it out.

Thanks

Hello,
I am quite OK with looptimer…
Here is an example:

[{"id":"10253bc3.00ab54","type":"api-call-service","z":"a0b5f92.ac23e08","name":"Sirene Porche Off","server":"34c2cae5.696246","version":1,"service_domain":"shell_command","service":"sirene_off","entityId":"","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":810,"y":290,"wires":[[]]},{"id":"96aa1535.973b38","type":"looptimer","z":"a0b5f92.ac23e08","duration":"1","units":"Second","maxloops":"3","maxtimeout":"3","maxtimeoutunits":"Second","name":"1 second","x":630,"y":290,"wires":[["10253bc3.00ab54"],[]]},{"id":"34c2cae5.696246","type":"server","z":"","name":"hadroid","legacy":false,"hassio":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true}]

So, in your case it would be something like:

[{"id":"33b7db43.57eca4","type":"looptimer","z":"a0b5f92.ac23e08","duration":"5","units":"Minute","maxloops":"8","maxtimeout":"40","maxtimeoutunits":"Minute","name":"5 Minutes","x":390,"y":50,"wires":[["f15eed58.05e21"],[]]},{"id":"f15eed58.05e21","type":"api-call-service","z":"a0b5f92.ac23e08","name":"Turn_on","server":"34c2cae5.696246","version":1,"debugenabled":false,"service_domain":"","service":"","entityId":"","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":550,"y":50,"wires":[["e3a249c6.80c468"]]},{"id":"e3a249c6.80c468","type":"delay","z":"a0b5f92.ac23e08","name":"","pauseType":"delay","timeout":"30","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":710,"y":50,"wires":[["a1c66468.4e6ab8"]]},{"id":"a1c66468.4e6ab8","type":"api-call-service","z":"a0b5f92.ac23e08","name":"Turn_off","server":"34c2cae5.696246","version":1,"debugenabled":false,"service_domain":"","service":"","entityId":"","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":850,"y":50,"wires":[[]]},{"id":"34c2cae5.696246","type":"server","z":"","name":"hadroid","legacy":false,"hassio":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true}]

GV

1 Like

Thank you so much @greengolfer, now I see the logic it’s so obvious!
I’ve already tested and implemented this code replacing what I had, so much simpler :slight_smile: