Trigger only if device state change is greater than X seconds


I’m very new to Home Assistant and I love it so far.

So, I have the following automations. If the TV is playing, then pause Sonos and if the TV is idle, then play Sonos.

It works well, so well in fact that it triggers even between channel switching in Tivimate, which I’d like to avoid of course.

Basically the title post, I’ve searched and tried a few options but I feel I’m missing something obvious.

Thank you.

Tl;dr: A condition to execute the action only if trigger (state change) is greater than 2 seconds.

use the for: config in your trigger.

Yes, I’ve tried that but Sonos never resumes playing.

Edit: The for option was for the TV becoming idle in my case.

I was just going on this…

Perhaps I have a different use case.

I think I need an and if condition. Something like state change > 00:00:02

and if what exactly?

so make it 3 seconds… I’m confused as to what exactly you are having trouble with.

why not just increase that for: value and deal with the Sonos having a longer delay before going back to playing?

This one:

I’ve tried for: but Sonos doesn’t play at all.

What happens if you just run the action? (in the 3 dot menu, top right of that block) I’m not seeing where you tell the Sonos what to play.

As it is now it works, Sonos is playing.

I don’t, it just resumes the playlist.

Ok, so put the 2 or 3 second for: time in the trigger, run through the operation of the TV and then look at the automation Trace to see what is happening.

I’ve put 3 seconds and when I run it, it works (instantly though) but in practise, when I stop the TV playing it doesn’t work. Strange…

I’ll try and make sense of Traces, thanks.