Temporarily Disable Lovelace Button After First Click

Hi, I’m working on a simple dashboard for my toddler (pictured below). Right now it can do two things:

  1. Stream mp3s to the google home in the room (top row).
  2. Control lights in the room (bottom two rows).

Streaming music takes a while and she can sometimes click the buttons multiple times causing songs to get randomly sent to her GH. As you might imagine, she gets quite fussy when things don’t work as she expects.

To ameliorate this, I’d like to disable the top row of buttons for ~15 seconds after she clicks one of them. Does anyone have a lead on how to do that? I imagine I can use a conditional card on that first row, but what I don’t know is how to go about setting state for 15 seconds that I could query from my conditional card.

In case it’s helpful, each of the top-row buttons calls a media_player service. Thanks!

You could add that to the automation. Have the button call an automation and build it in to the automaiton to not allow it to run before x amount of time since the last run of the automation:

https://community.home-assistant.io/t/solved-prevent-run-if-already-run-in-last-10-mins/122218/4

or you could put an artificial delay of 15 seconds (sleep) at the end of the automation and ensure mode is ‘single’ in the automation. You would need the delay at the end since the HA part could complete and the media player is the delay, so you would need to intentionally put in the sleep function to keep the automation alive so the single mode sees it is still running and won’t execute another instance.

https://www.home-assistant.io/docs/automation/modes/

Thanks! That first link proved most useful (used in ingredient 3 below). I ended up getting my desired functionality with 4 ingredients:

  1. script for playing media called play_music_in_nursery
  2. binary_sensor to check if it has been 10 seconds since the above script has been called:
template:
  - binary_sensor:
    - name: can_play_music_in_nursery
      state: >
        {{ ( as_timestamp(now()) - as_timestamp(state_attr('script.play_music_in_nursery', 'last_triggered')) | int(0) ) > 10 }}
  1. lovelace buttons that play media via my script
  2. conditional card that only displays those buttons if binary_sensor.can_play_music_in_nursery