How can I exit this repeat?

So thanks to this wonderful guide I've been able to get some alternating porch light animations running, using my Osram gardenspots. I've leveraged Rule Machine to create a fun animation that runs three strings (Porch North/South/Center) through alternating red/green sequences, and it's brilliant. My only problem is, the porch is also next to my bedroom window, and I'm having a wee bit of trouble getting the thing to stop once it gets going. Here's the rule:

"Christmas Decorations" is a Room Lighting app that turns on four devices: the aforementioned Porch North/Center/South strings, and a virtual switch named "Porch Animation Toggle". The trigger works perfectly here; once I invoke Christmas Decorations by turning it on (programmatically, typically, with an Alexa routine), the rule fires up and starts sequencing the animation.

"Repeat Fuzzer" is a local variable in the rule set to 8, so I can speed up or slow down the animation sequence if I want.

So, that repeat will run ad infinitum as long as the virtual switch "Porch Animation Toggle" is on. I've written a helper rule that's supposed to turn it off when all three strings are turned off:

When I'm ready for bed, I have an evening routine that shuts off almost everything, including the outdoor porch lights, which should trigger this rule and get it to switch off the virtual switch "Porch Animation Toggle," with the intent being to break the repeat loop in the Christmas Animations.

However, it doesn't reliably do so. Usually the repeat on the animations turns everything back on again and then picks up where it left off.

Is there a better way to catch an exit event in the animations loop?

I've been able to improve this by making my helper rule trigger by switch off rather than digital off of the string lights, and sticking a final cleanup in the main animations rule:

"Stop Animations" rule:

"Christmas Animations" rule:

Now, the "off" event is detected more reliably, and sets the virtual switch to the desired toggle value. If this occurs mid-loop, the lights do again turn on for the next step, but the final cleanup event at the end outside the loop gets them back off. So we get where we need to go. I'm definitely still open for feedback on improving this, but it's functional now. :slight_smile:

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.