How can I play random Soundboard sound?

Hi

I have a door sensor that triggers a flow, and would like to randomly play a Soundboard sound of 3 specific sounds on my Sonos, how can I achive this? :slight_smile:

Best Regards
Stig

You can try this https://community.homey.app/t/random-number/18502
And if a variable is 1 play audio 1, variable is 2 play audio 2 and if the variable is 3 play audio 3

I don’t use it myself.

Thank you Mike, that helps alot, at least I can get a random number to work with now … But I am not able, in the Flows to make a IF RandomNum = 1 THEN, ELSEIF RandomNum = 2 THEN, ELSEIF… so what would be the best approach for doing this in a flow?

How to work with ELSIF I have no idea at the moment.
But you can add 3 more extra flows. It is the most easy.
IF random nubber is 1
THEN start a flow Audio 1

Flow Audio 1
IF this flow is started
THEN play audiofile…

And so in for 2 and 3.

You can use it this way

  • Flow 0.4 Play 3 Sounds Random
    If…
    Contact alarm went on
    Then…
    Logics: Calculate a numeric variable [RandomSoundSelected] as [RandomSoundN#]

  • Flow 1.4 Play 3 Sounds Random
    If…
    [RandomSoundSelected] has changed
    And…
    [RandomSoundSelected] is exactly 1
    Then play Sound1
    Else…
    Start flow ‘2.4 Play 3 Sounds Random’

  • Flow 2.4 Play 3 Sounds Random

And so on

2 Likes

Thank you so much @Peter_Kawa that was exactly what I was looking for :partying_face:

1 Like