Turn off timer issue

Hello guys,
i wanted to create a simple “turn-off timer” rule for my sound receiver which is connected to Alexa.
The connected Alexa dot is implemented in 3 different groups (Echo_Wohnzimmer_Player, Echo_Wohnung_Player, Echo_Wohnungbereich_Player). So i want to check if really all groups are in PAUSE.
Problem is that when alexa is changing music titles the player is jumping to PAUSE and back to PLAY very quickly. I want to avoid that my Sound Receiver is turn off by this, so i wanted to check 10s later if all Groups are still in Pause to turn the Receiver finally off.

However sometime this is not working an the OFF-command is not send. Even if all Groups are still in pause. I dont know the reason. Maybe something is wrong with the timer?

var Timer timer = null
rule "Alexa Wohnzimmer AUS"
    Item Echo_Wohnzimmer_Player changed from PLAY to PAUSE or
    Item Echo_Wohnung_Player changed from PLAY to PAUSE or
    Item Echo_Wohnungbereich_Player changed from PLAY to PAUSE
            if (timer === null) {
            timer = createTimer(now.plusSeconds(10), [ |
                if (Echo_Wohnzimmer_Player.state == PAUSE  && Echo_Wohnung_Player.state == PAUSE  &&  Echo_Wohnungbereich_Player.state == PAUSE) { 
        } else {
            if(timer!==null) {
                timer = null

Does someone have an idea?
I am lost :frowning:

My understanding is that you want to send an OFF command to the receiver 10s after the last one changes from PLAY to PAUSE. In your current rules, when one of your Echo players changes from PLAY to PAUSE, it starts a timer. After that timer executes, it is not null, so when the next player changes to PAUSE, the timer is set to null rather than starting a timer.

Take a look at the createTimer Action. In the if, add an or operator and hasTerminated. In the else, remove everything you have and a reschedule. That should get it working the way you want it to.