Best type of button to trigger playing of audio file

With so many different card types, what is the best type of button entity to use if I want to create a button that I can press to trigger an audio file to be played on a speaker. One the button is pressed, the button should be inactive until the audio file is done playing (or a specified duration). The context here is that I have cameras monitoring my front steps and sometimes people sit on them–when this happens I want to press a button to play a recording telling them that they are trespassing and need to move along.

Any thoughts?


I have created an input-boolean helper as a switch. Then made an automation, which plays media on a speaker, when the switch is turned on, another one, which stops playing, when the switch is turned off. You can create an mp3-file online, which makes an mp3 of the typed text, what you want to be played on your speaker. Then I integrated this helper in a chips card.

Hope, that helps.

I don’t have a solution at hand but I don’t think you will find a solution with the kind of button you use, it has to be in the automation (or script).
As Blackway mentioned, you could solve it with a helper that you switch on/off at the start/end of the automation/script with a delay at the end which represents the time you don’t want the automation/script to run again.

@Blackway Thank you. I followed your suggestion. I created a input-boolean which I turn on through a custom button card. Then I created an automation that runs when the input-boolean is on. This automation runs the commands that plays the audio file. Many thanks!

@Cold-Lemonade I’m glad to hear that. Please give me a like and mark my answer as solution - thanks!

Was that the intention: to create an extra action before the automation can run?

I was under the impression that you wanted to block the ability to play the audio file while it’s playing.
If your goal was to prevent playing the file while it’s playing: use that input-boolean as a condition, switch it on and off in the automation with a delay in between that represents the time you want to prevent from playing the audio file again.