Reset volume 30 minutes after a button has been pressed and the player was stopped

I would like to set the volume of a media player to a defined value 30 minutes after the player has been stopped. But only if the player was stopped by pressing a button.
If I control the player via the native app, the volume should not be reset.
I know how to stop the player by pressing a button, and I know how to reset the volume after a certain time.But I am not clear how to link everything together.
What is the best way to realize this?

Best, and many thanks
Andreas

Welcome to the forums!

One way could be using 2 helpers, an input_button or and input_boolean (= trigger) and an input_number (=. will survive HA restarts):


trigger:

  - platform: state
    entity_id: input_button.your_input_button

action:

  - service: media_player.media_stop
    target:
      entity_id: media_player.your_player

  - delay:
      minutes: "{{ states('input_number.your_input_number')|float(30) }}"

  - service: media_player.volume_set
    data:
      volume_level: 0.3
    target:
      entity_id: media_player.your_player

Thank you very much!