Need some help with simple volume changing template/ script/ automation (log error included)

Hello all,

Can I get some help with getting the below script working? Essentially I am getting the log error shown in the second paste below. Thank you all for any guidance you can give!!

  alert_notify:
    variables:
      original_volume: "{{ states('input_number.current_speaker_volume')|int(0) }}"
    sequence:
      - condition: state
        entity_id: input_boolean.vacation_mode
        state: "off"
      - service: tts.google_cloud_say
        data_template:
          entity_id: >
            {% if who == 'back porch' %}
              media_player.back_porch_speaker
            {% elif who == 'front porch' %}
              media_player.front_porch_speaker
            {% elif who == 'dining room' %}
              media_player.dining_room_wifi
            {% elif who == 'office' %}
              media_player.office_wifi
            {% elif who == 'master bedroom' %}
              media_player.master_bedroom_speaker
            {% elif who == 'master bathroom' %}
              media_player.master_bathroom_speaker
            {% elif who == 'gym' %}
              media_player.gym_speaker
            {% elif who == 'guest bedroom' %}
              media_player.guest_bedroom_speaker
            {% elif who == 'garage' %}
              media_player.garage_speaker
            {% elif who == 'guest bathroom' %}
              media_player.guest_bathroom_speaker
            {% elif who == 'everywhere inside' %}
              media_player.everywhere_inside
            {% elif who == 'kitchen' %}
              media_player.kitchen_display
            {% else %}
              media_player.sonos_group
            {% endif %}
          message: >-
            {{ message }}
      - service: media_player.volume_set
        data_template:
          entity_id: >
            {% if who == 'back porch' %}
              media_player.back_porch_speaker
            {% elif who == 'front porch' %}
              media_player.front_porch_speaker
            {% elif who == 'dining room' %}
              media_player.dining_room_wifi
            {% elif who == 'office' %}
              media_player.office_wifi
            {% elif who == 'master bedroom' %}
              media_player.master_bedroom_speaker
            {% elif who == 'master bathroom' %}
              media_player.master_bathroom_speaker
            {% elif who == 'gym' %}
              media_player.gym_speaker
            {% elif who == 'guest bedroom' %}
              media_player.guest_bedroom_speaker
            {% elif who == 'garage' %}
              media_player.garage_speaker
            {% elif who == 'guest bathroom' %}
              media_player.guest_bathroom_speaker
            {% elif who == 'everywhere inside' %}
              media_player.everywhere_inside
            {% elif who == 'kitchen' %}
              media_player.kitchen_display
            {% else %}
              media_player.living_room_sonos_speaker
            {% endif %}
          volume_level: >
            {{ states('input_number.current_speaker_volume') | float }}
      - service: input_number.set_value
        value: "{{ original_volume }}"
        entity_id: input_number.tts_volume
2023-12-20 11:26:38.906 ERROR (MainThread) [homeassistant.components.script] Script with object id 'alert_notify' could not be validated and has been disabled: extra keys not allowed @ data['sequence'][3]['value']. Got '{{ original_volume }}'
      - service: input_number.set_value
        data:
          value: "{{ original_volume }}"
        target:
          entity_id: input_number.tts_volume

Thank you @123 Very helpful!!

1 Like