Having issues with script. (While loop and TTS)

First time using a while loop. I've used TTS recently with Chromecast beta and Google home but for some reason in this specific rule, something's not working and TTS doesn't activate.

Need some help trouble shooting

General premise. I want a 1 minute timer before announcing that the refrigerator door has been left open.

My thought was to have a local variable Fridge counter increment up every 5 seconds in case the refrigerator door was closed before the one minute interval.

To me everything looks right but I must be misunderstanding how this works.

All other instances of TTS are functioning normally

Thanks in advance for your assistance

I imagine this would have great waf in my house NOT...lol

Use wait for event 60 secs instead and recheck

Hmm.I'm new at this programming. If you could explain in more detail on how to do that, it would be greatly appreciated.

Would your option reset the trigger if the door was closed earlier than the 1 minute window?

Your END-REP needs to be after the END-IF. As it is, you are only repeating the Addition of “1” to your FridgeCounter.

That's just my rudimentary timer that kicks out of the loop if the door closes early.

If I put everything in the loop the notification would go off all the time

Ah yes! Why not use a wait for elapsed time = 1 minute and the you could remove the FridgeCounter from your IF condition?

Where is this "while" loop option? I saw this in the release notes at one point but I've still been using a simple conditional to accomplish this.

I would also just use the wait and recheck function as others have mentioned, but here is a rule that I use to limit TV Time for my kids. Very similar to what you're trying to do. The biggest difference is that I'm only running this rule for a defined time window after school and when the kids are likely to be unsupervised.

Your rule would still use your trigger, would likely use the while loop to repeat itself, and two nested IF statements. One to increment your timer and one to make the announcement when the timer value equals 60. After the END-REP you would reset the timer to 0.

EDIT: you could also add an ELSE-IF FridgeCounter = 120 speak 'Now you've done it, I'm telling!' And start flashing the lights, sounding sirens, etc. Really go all out on this one... :wink:

EDIT2: I reread your first post and want to clarify. You won't need an IF statement to increment your variable since the open door condition is already required by your while loop. Also, instead of FridgeCounter = 60 (or 120) conditions as I indicated, they would be 12 (or 24) as you've shown in the screenshot.