I finally solved my issue of multiple Alexa notifications interrupting one another

My good_morning script message was often interrupted by other automations/scripts triggering and speaking out of turn. Now, all notity.alexa_media using sensor.last_alexa occurrences execute the one script in queued mode with a delay factor after the service call based on the word count in the message.

script.notify_alexa_media

alias: Notify Alexa Media
description: Send notification to sensor.last_alexa
fields:
  message:
    description: The message content
    example: I am notifying you
sequence:
  - service: notify.alexa_media
    continue_on_error: true
    data:
      message: "{{ message }}"
      data:
        type: tts
      target: "{{ states('sensor.last_alexa') }}"
  - delay:
      seconds: "{{ (message.split(' ') | count * 0.5 ) | round(0, 'floor', default) }}"
mode: queued
icon: mdi:account-voice
max: 10

script.good_morning

alias: Good Morning
sequence:
  - service: input_select.select_option
    data:
      option: Awake
    target:
      entity_id: input_select.sleep_status
  - service: input_boolean.turn_on
    data: {}
    target:
      entity_id: input_boolean.bedroom_automatic_lights
  - service: input_boolean.turn_off
    data: {}
    target:
      entity_id:
        - input_boolean.sleep_mode
        - input_boolean.daniel_sleeping
  - choose:
      - conditions:
          - condition: state
            entity_id: binary_sensor.night_mode
            state: "off"
        sequence:
          - service: cover.set_cover_position
            data:
              position: "{{ states('input_number.bedroom_blind') }}"
            entity_id: cover.bedroom_blind
    default:
      - service: light.turn_on
        data:
          transition: 90
          brightness_pct: 70
        target:
          area_id: bedroom
  - choose:
      - conditions:
          - condition: state
            entity_id: input_boolean.coffee_prepared
            state: "on"
        sequence:
          - service: script.activate_alexa_actionable_notification
            data:
              text: Would you like me to start your coffee?
              event_id: actionable_notification_make_coffee
              alexa_device: "{{ states('sensor.last_alexa') }}"
          - wait_for_trigger:
              - platform: event
                event_type: alexa_actionable_notification
            timeout: "00:00:15"
      - conditions:
          - condition: numeric_state
            entity_id: input_number.coffee
            below: "18"
        sequence:
          - service: script.notify_alexa_media
            data:
              message: You forgot to buy coffee!
      - conditions:
          - condition: numeric_state
            entity_id: input_number.coffee_filter_count
            below: "1"
        sequence:
          - service: script.notify_alexa_media
            data:
              message: You don't have any coffee filters!
    default:
      - service: script.notify_alexa_media
        data:
          message: I'm sorry, It looks like you'll have to make your own coffee
      - delay:
          hours: 0
          minutes: 0
          seconds: 6
          milliseconds: 0
  - service: script.notify_alexa_media
    data:
      message: >
        The temperature outside is {{
        states("sensor.outside_weather_temperature")|round(1)|replace(".0","")
        }} {% if states("sensor.outside_weather_temperature")|replace(".0","")
        != "1" -%} degrees {%- else -%} degree {%- endif -%} {% if
        states("sensor.norton_court_realfeel_temperature") != "unknown" and
        states("sensor.norton_court_realfeel_temperature") !=
        states("sensor.lumi_lumi_weather_temperature") %} but it feels like {{
        states("sensor.norton_court_realfeel_temperature") }} {%- if
        states("sensor.norton_court_realfeel_temperature")|replace(".0","") !=
        "1" %} degrees.{%- else %} degree.{%- endif -%} {%- else %}. {%- endif
        %} The living room is currently {{
        state_attr("climate.living_room","current_temperature")|round(1,"half")|replace(".0","")
        }} degrees and the heat is {%- if is_state("climate.living_room", "off")
        %} turned off. {%- else %} set to {{
        state_attr("climate.living_room","temperature")|round(1,"half")|replace(".0","")
        }} {%- endif %}
  - if:
      - condition: state
        entity_id: sensor.season
        state:
          - autumn
          - winter
    then:
      - service: climate.set_preset_mode
        data:
          preset_mode: none
        entity_id: climate.living_room
      - delay:
          hours: 0
          minutes: 0
          seconds: 1
          milliseconds: 0
      - if:
          - condition: numeric_state
            entity_id: climate.living_room
            attribute: temperature
            below: input_number.hvac_temperature
        then:
          - service: climate.set_temperature
            data:
              temperature: "{{ states('input_number.hvac_temperature') }}"
            target:
              entity_id: climate.living_room
          - service: script.notify_alexa_media
            data:
              message: >-
                I've set the heat to
                {{states("input_number.hvac_temperature")|replace(".0","")}}
          - delay:
              hours: 0
              minutes: 0
              seconds: 4
              milliseconds: 0
            enabled: false
  - choose:
      - conditions:
          - condition: state
            entity_id: sensor.garbage
            state: "0"
          - condition: state
            entity_id: input_boolean.garbage_is_out
            state: "off"
          - condition: time
            before: "08:30:00"
            weekday:
              - wed
            after: "00:00:00"
        sequence:
          - service: script.notify_alexa_media
            data:
              message: You might still have time to put the garbage out.
  - choose:
      - conditions:
          - condition: state
            entity_id: sensor.recycling
            state: "0"
          - condition: state
            entity_id: input_boolean.recycling_is_out
            state: "off"
          - condition: time
            before: "08:30:00"
            weekday:
              - thu
              - fri
            after: "00:00:00"
        sequence:
          - service: script.notify_last_alexa
            data:
              message: You might still have time to put the recycling out
  - service: script.notify_alexa_media
    data:
      message: >
        The temperature outside is {{
        states("sensor.outside_weather_temperature")|round(1)|replace(".0","")
        }} {% if states("sensor.outside_weather_temperature")|replace(".0","")
        != "1" -%} degrees {%- else -%} degree {%- endif -%} {% if
        states("sensor.norton_court_realfeel_temperature") != "unknown" and
        states("sensor.norton_court_realfeel_temperature") !=
        states("sensor.lumi_lumi_weather_temperature") %} but it feels like {{
        states("sensor.norton_court_realfeel_temperature") }} {%- if
        states("sensor.norton_court_realfeel_temperature")|replace(".0","") !=
        "1" %} degrees.{%- else %} degree.{%- endif -%} {%- else %}. {%- endif
        %} The living room is currently {{
        state_attr("climate.living_room","current_temperature")|round(1,"half")|replace(".0","")
        }} degrees and the heat is {%- if is_state("climate.living_room", "off")
        %} turned off. {%- else %} set to {{
        state_attr("climate.living_room","temperature")|round(1,"half")|replace(".0","")
        }} {%- endif %}
mode: single
icon: hass:weather-sunset-up
2 Likes

Cool idea!

I thought so too! It only took me 1½ years to think of it :roll_eyes: :grinning_face_with_smiling_eyes: