Create a Loop - Repeat an alarm 5 times unless door opened

Hi, I have a working alarm in NodeRed for a deep sleeping 17yo that at 6:30am on weekdays, checks his Mum’s Google Calendar (HA Integration), using a switch node, to make sure it’s not a school holiday, checks to make sure his light is turned off (he may have gotten up early), then fades his light in over 30 seconds and plays Du Hast at 80% volume on his Google Home.

Apparently that’s not enough because he can swat the Google Home to silence it and then ask it to turn off his light. I have recently installed a door sensor on his door and what I want to achieve is that his alarm will go off 5 times, at 90 second intervals, unless he gets up and opens his door, which will stop the alarm flow. I imagine that the loop would go after the check to see if his light is on, and would include the service call for his light and to Google Home to play the song. I just can’t work out how to make the “loop” in NodeRed.

Have you tried to use this?
just an example

As often in node-red, there is a node for that!! Search for node-red-contrib-looptimer
In your case, put this node after “light off”. Configure the loop node to do its magic 5 times at 90 seconds interval. If the door is opened, then send a stop to the loop node.


1 Like

many thanks @greengolfer, that turned out to be exactly what I was after. Once again NodeRed delivers. I am constantly amazed at its flexibility.

Now, if the door opens a payload of “stop” is sent to a Time Range node which just checks that the time is betwen 5:55am and 7:00am and if true sends the stop payload to the Loop Timer Node. Perfect.

thanks for the reply Malaga82, but it was the loop part that was the struggle, getting the action to repeat 5 times but then stop if the door opened. LoopTimer turned out to be just the ticket.

Could you please provide a picture of this?
Just trying to figure out how to get the stop signal into the timer.

I used a Trigger State Node for the door : if previous state is OFF, and current state is ON, send custom payload of “stop”. I filtered that through a Time Range node so that the “stop” command would only be sent between 5:30am and 9:00am. If the command made it through the time filter, that fed into the left hand side of the LoopTimer, causing it to stop.

Trigger node has this option to keep resending at interval until msg.reset is received. Here I have send a notification every 5 minutes if my autogate has been opened for more than 30 minutes and send a msg.reset if the gate is closed.