Timing of playing audio alerts

Hey all,

I have a rule where I tell OH that I’m going to bed. It turns off a bunch of stuff then plays two audio files

The first is a basic “good night - the house is in night mode” type message
Then the script looks for open doors. If there are none- It says “All doors are closed” if there are is tells me what doors are open.

So, I’m trying to play two audio files back to back. What I found is that they just play over one another making it not possible to understand them.

I had been using two executeCommandLine() commands and playing through an external command, but I spent some time to convert over to the playSound() command and it does the same thing.

Basically what I resorted to is putting in a 3 second sleep between the commands:

Thread::sleep(3000)

Is there another way to do this? I’m worried that sometimes the 3 seconds might not be enough.

Not really!
The play command doesn’t wait for the previous one to be finished.
Use a timer instead of your long sleep

play("something")
createTimer(now.plusSeconds(3), [ |
    play("somethingelse")
])

Thanks for the reply. Is there an advantage to the timer vs the sleep?

Yes, it doesn’t clag up the rule engine twiddling it’s thumbs (and potentially blocking other rules from running). createTimer is more like an alarm clock, set and forget.