Managing volume in notify.alexa_media

i am also interested in this and have a possible way to start from. I think it’s not possible to notify all echo devices at once but with a delay this is working: (you need to create a group with all echo devices mine is group.all_media_players)

  sequence:
    - variables:
        players_and_volume: >
              {% set x = expand('group.all_media_players')
                  | list %}
              {% set ns = namespace(result=[]) %}
              {% for s in x %}
                {% set ns.result = ns.result + [ [s.entity_id, s.attributes.volume_level] ] %}
              {% endfor %}
              {{ ns.result }}
    - repeat:
        count: '{{ players_and_volume | count }}'
        sequence:
        - delay: "00:00:02"
        - variables:
            player_and_volume: '{{ players_and_volume[repeat.index - 1] }}'
        - service: media_player.volume_set
          data_template:
            entity_id: "{{ player_and_volume | first }}"
            volume_level: "0.03"
    - delay: "00:00:02"
    - repeat:
        count: '{{ players_and_volume | count }}'
        sequence:
        - delay: "00:00:02"
        - variables:
            player_and_volume: '{{ players_and_volume[repeat.index - 1] }}'
        - service: notify.alexa_media
          data_template:
            target: "{{ player_and_volume | first }}"
            data:
              type: tts
            message: "A"
    - delay: "00:00:02"
    - repeat:
        count: '{{ players_and_volume | count }}'
        sequence:
        - delay: "00:00:02"
        - variables:
            player_and_volume: '{{ players_and_volume[repeat.index - 1] }}'
        - service: media_player.volume_set
          data_template:
            entity_id: "{{ player_and_volume | first }}"
            volume_level: "{{ player_and_volume | last }}"

got the idea from Repeat same action on multiple person - how to optimise this automation? - #5 by 123 and Get multiple mapping values in templating - #2 by 123

1 Like