Lights get stuck in flicker loop

I have a simple automation to tun on a few lights when another is on and then to turn off the same lights when one is off.

The issue is that sometimes someone flips the switch before the automation completes resulting in my lights flickering until i restart or unplug my hass.io box.

Is there a way to add a “if you just did this don’t do it again for 10 seconds” or something to my automation?