Qualify a Node Red automation with scene activation

I have a scene that turns off all lights and our TV when it’s time to go to bed. I also have a Node Red automation that dims the family room lights when we turn on the TV and turns them back up to full when we turn off the TV.
Maybe you’ve already spotted the problem… :slight_smile:
When I activate the scene, intending to turn off the lights, the lights turn off, then back on again (because the TV state change activates the automation).
Is it possible to prevent this automation from running if the TV was turned off due to activation of the scene?

The scene could also turn off a dummy switch (eg. template/mqtt), and then only allow the Node Red flow to continue if the switch is on. You might also have to introduce a slight delay on the NR end, or you may occasionally get a race condition. You could turn the switch back on at the start of the day, or in the NR flow after the test of the switch if it’s off.

If you’re running the scene from NR, you could alternatively use a flow/global variable rather than a switch (assuming you’ve also set contextStorage to “localfilesystem”.

Thanks. Great idea :).
I ended up using a toggle helper instead of a dummy switch (since I knew how to make the former). This seems to be working fine.
Dan