# How can I play random Soundboard sound?

**URL:** <https://community.homey.app/t/how-can-i-play-random-soundboard-sound/61556>\
**Category:** Questions & Help\
**Created:** [March 11, 2022, 7:11am UTC](https://community.homey.app/t/how-can-i-play-random-soundboard-sound/61556 "2022-03-11T07:11:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stig\_Kolbaek](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/stig_kolbaek/32/51393_2.png) [@Stig\_Kolbaek](https://community.homey.app/u/Stig_Kolbaek)\
**Post date:** [March 11, 2022, 7:11am UTC](https://community.homey.app/t/how-can-i-play-random-soundboard-sound/61556/1 "2022-03-11T07:11:28Z")

</div>

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? 🙂

Best Regards  
Stig

---

<div class="post-metadata">

**Author:** ![Mike1233](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/mike1233/32/20991_2.png) [@Mike1233](https://community.homey.app/u/Mike1233)\
**Post date:** [March 11, 2022, 8:27am UTC](https://community.homey.app/t/how-can-i-play-random-soundboard-sound/61556/2 "2022-03-11T08:27:55Z")

</div>

You can try this [https://community.homey.app/t/random-number/18502](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.

---

<div class="post-metadata">

**Author:** ![Stig\_Kolbaek](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/stig_kolbaek/32/51393_2.png) [@Stig\_Kolbaek](https://community.homey.app/u/Stig_Kolbaek)\
**Post date:** [March 11, 2022, 8:47am UTC](https://community.homey.app/t/how-can-i-play-random-soundboard-sound/61556/3 "2022-03-11T08:47:19Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Mike1233](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/mike1233/32/20991_2.png) [@Mike1233](https://community.homey.app/u/Mike1233)\
**Post date:** [March 11, 2022, 9:41am UTC](https://community.homey.app/t/how-can-i-play-random-soundboard-sound/61556/4 "2022-03-11T09:41:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [March 11, 2022, 10:21am UTC](https://community.homey.app/t/how-can-i-play-random-soundboard-sound/61556/5 "2022-03-11T10:21:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Stig\_Kolbaek](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/stig_kolbaek/32/51393_2.png) [@Stig\_Kolbaek](https://community.homey.app/u/Stig_Kolbaek)\
**Post date:** [March 11, 2022, 11:35am UTC](https://community.homey.app/t/how-can-i-play-random-soundboard-sound/61556/6 "2022-03-11T11:35:45Z")

</div>

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