Wait for volume level set automation

I am trying to set an automation to announce on my amps/speakers that someone has rung the doorbell. As part of the automation I’d like to set the volume of the player before it plays, then change it back again after.

The automation works, but by the time the sound has played, the automation has already set the volume back to the lower level. I need some kind of “wait step” so that the automation holds on playback until the volume change has been confirmed.

The “wait for trigger” doesn’t seem to have an option for volume, so I’m guessing I need to use the “wait for a template”, but I’m not sure how to set that.

Below is the action section of the automation so far:

Any help would be greatly appreciated.

actions:
  - action: media_player.volume_set
    metadata: {}
    data:
      volume_level: 0.53
    target:
      entity_id: media_player.dining_room_2
  - delay:
      hours: 0
      minutes: 0
      seconds: 10
      milliseconds: 0
  - action: media_player.play_media
    target:
      entity_id: media_player.dining_room_2
    data:
      media_content_id: media-source://media_source/local/2FilesMerged_20241121_144325.mp3
      media_content_type: audio/mpeg
    metadata:
      title: 2FilesMerged_20241121_144325.mp3
      thumbnail: null
      media_class: music
      children_media_class: null
      navigateIds:
        - {}
        - media_content_type: app
          media_content_id: media-source://media_source
  - wait_for_trigger:
      - device_id: 01eb1025dc15253e20f5cd06eef350f6
        domain: media_player
        entity_id: 0bed1893e7dec353eaf66fae5e01dff7
        type: idle
        trigger: device
  - action: media_player.volume_set
    metadata: {}
    data:
      volume_level: 0.17
    target:
      entity_id: media_player.dining_room_2
mode: single

Wait for trigger doesn’t have ‘volume’

But I bet that volume is an entity with a state? If so, wait for trigger absolutely takes entity states

(and most flexibility comes from using states instead of just about anything else.)

For what reason do you have the 10 second delay after adjustig the volume to high?

If you want the sound to play after the volume change is in effect you can use wait for template with the following template:

{{ is_state_attr('media_player.dining_room_2','volume_level', 0.53) }}

This works, thank you.