How to Stop a Flow During a Lighting Loop?

Not a programmer, so apologies that I'm likely using incorrect terminology to ask. My favorite new node red automation uses a Home Assistant helper to trigger whenever a color scheme is selected. It then checks to see if any smart lightbulbs are on, changes them to various colors based on the selected color scheme, and repeats at random intervals.

The problem is that when I turn off a light that's looping through colors, it often flashes like crazy or turns back on a second later (presumably because it's in the middle of transitioning to another color). The best solutions I've cobbled together are... not great (e.g. adding Current State nodes everywhere to check if the light is off, or triggering additional "turn off" commands on a delay in case the first one didn't take. Neither is totally effective).

Here's what the flow looks like, along with my "Cool" color scheme subloop. Any help is appreciated!


Hi, I just posted a function node that will allow you to single step.

It may help you find the problem. https://discourse.nodered.org/t/message-debug-function-node/53261