Repeat Actions RM Help

Hi, new to Habitat and I'm trying to create a smart alarm clock using the withings sleep pad and Echo Dot for the 'sound' portion of the alarm.

Essentially if it is now Day mode and I'm still in bed I want alarm to play through echo. Once I get up the alarm sound will turn off. However, I'm working/figuring out how to handle if I 'snooze' the alarm by changing the status to stopped or paused.

So I'm trying to incorporate a while loop to check after 10 seconds if I'm still in bed and the echo was paused it will start playing again.

The conditional variables I'm using:
In Bed Switch = still in bed -> ON, out of bed -> Off (Using IFTTT)
Mode = day mode
Alexa Stopped Switch = Alexa stopped or paused -> On, Alexa playing -> Off

Here is what I currently have (Can't post screenshots):

Trigger is if Bed Switch changed

IF (In Bed Switch(off) is on(F) AND
Mode is Day(T) [FALSE]) THEN
setVolume(50) on Echo - Cole' Echo Dot
searchAmazonMusic('Shuffle Playlist, Wake Up: Dance') on Echo - Cole' Echo Dot
** While Loop to be inserted ***
Delay 0:00:15
IF (In Bed Switch(off) is on(F) AND
Alexa Stopped Switch(on) is on(T) [FALSE]) THEN
play() on Echo - Cole' Echo Dot
ELSE-IF (Mode is Day(T) AND
In Bed Switch(off) is off(T) [TRUE]) THEN
pause() on Echo - Cole' Echo Dot

Thanks in advance

I’m sitting at a work site in the parking lot on my phone, so I can’t get to detailed but look at maybe using a wait for condition or event. That is basically what your repeat loop is doing.

So in the context of this example if I have a wait condition of (Bed Switch -> ON AND Alexa Stopped Switch -> ON) THEN Play sound. So now once the play sound is activated the Alexa Stopped Switch -> OFF, would this not exit the loop and if I stopped Alexa again it wouldn't trigger?

similar issue- and forgive me for reviving an older thread
i am running a repeat loop to flash an LED (the output device does not respond to the "flash" command")
the action executes upon the trigger input going ON but does not stop/exit the repeat loop when the trigger input goes off. No doubt i have missed something here.
Slap my wrist if this is a frowned upon method to flash the output.

You have nothing in the loop to stop it.

You need to have a Stop repeating, Below is test rule I was playing with. It uses a repeat that starts when a switch turns on then stops when it turns off

thanks for the advice, @terminal3 following your post here's my revised rule

Guessing i need the trigger input to be "change of state" in order to run the rule as if it was triggered by ON or OFF it will only run on that instance.

Please correct me if improvements can be made here

PS- looking at your rule (above) it would seem logical to me that as your rule runs when the garage fan goes ON but when it goes OFF the rule would then not be executed and therefore the "stop repeating" actions never gets reached. Or I have i misunderstand?

Just revise to this

Trigger: Header_tank_overflow turns on
ACTION: 
While ("header_tank_overflow is on") repeat every 0:00:00.5
      Toggle: Alarm panel led
END-REP
Off: alarm panel led
2 Likes

The rule is executed when the fan turns on, that is what triggers it. It remains in the loop until the fan is turned off. The If statement executes once the fan turns off. Once a loop is triggered it loops until it exits you don't need to trigger it again.

So you only need to set the trigger on being turned on. If you set it to both, then it will trigger when the switch goes off and will probably give you one more toggle of the LED.

That rule I posted doesn't really do anything useful it was just a test. It was just to show you the general structure of a loop. The while loop is probably a better way to go.

thanks again, @terminal3 , you've been my tutor today :wink: