Skip to content
caiosweet edited this page Feb 15, 2023 · 7 revisions

Examples Alexa

Send a custom message only for Alexa

service: script.my_notify
data:
  notify: False
  alexa:
    message: Speak only Alexa

Alexa Boolean option

Activate Alexa and send the same message as the text notifications.

service: script.my_notify
data:
  message: Primary message for text notifications.
  alexa: True

Media player

service: script.my_notify
data:
  message: Primary message for text notifications.
  alexa:
    media_player: Sala # CHANGE ME

Media player list

You can enter a list of media players, using the name, entity or both.

service: script.my_notify
data:
  message: Primary message for text notifications.
  alexa:
    media_player: Sala, Studio, media_player.sala # CHANGE ME

Volume

Set the preferred volume for this notification.

service: script.my_notify
data:
  message: Set the volume to 50%.
  alexa:
    volume: 0.5

Type tts

service: script.my_notify
data:
  message: Set type to tts.
  alexa:
    type: tts

Type announce

service: script.my_notify
data:
  message: Set type to announce.
  alexa:
    type: announce

Send a sound from home assistant

Note the following requirements and limitations The file used for this test can be found in the sounds folder ! still work?

service: script.my_notify
data:
  alexa:
    message: test
    ssml: true
    audio: https://YOURDOMAIN.duckdns.org/local/comic.mp3

Last Alexa

In this example, you need the sensor.last_alexa

service: script.my_notify
data:
  alexa:
    message: "Abracadabra! This is, the last alexa sensor"
    media_player: Last Alexa

Sensor Notifier Player Alexa

Of course, you can use the sensor in the package or your own specific one, provided that it has in the state one or more media player entities.

service: script.my_notify
data:
  alexa:
    message: "ding ding ding. This is the notifier sensor"
    media_player: sensor.notifier_player_alexa

Send tts and push message at the same time

service: script.my_notify
data:
  alexa:
    message: Alpha one-two, this is X-ray two-three, ROGER, OUT
    title: Push notifiction
    push: true

Language and voice-id

If SSML is not active, you will hear Alexa’s normal voice.

service: script.my_notify
data:
  alexa:
    message: "Houston, we have a problem!"
    language: en-US
    voice: Matthew

SSML

If SSML switch is not active, the ssml option can force activation.

service: script.my_notify
data:
  alexa:
    message: "Houston, we have a problem, here!"
    ssml: true
    language: en-US
    voice: Joey

Prosody and whisper

If whisper is true, it will apply a whispering effect to the speech.

service: script.my_notify
data:
  alexa:
    message: >
      Parlo piano e a bassa voce. Sono le 11 Buonanotte e sogni d'oro!
    ssml: true
    whisper: true
    rate: 80
    ssml_volume: 4.1
    type: tts
    volume: 0.4

Audio

Audio Amazon Sounds

service: script.my_notify
data:
  alexa:
    ssml: true
    audio: soundbank://soundlibrary/foley/amzn_sfx_clock_ticking_01

Audio 2

service: script.my_notify
data:
  alexa:
    ssml: true
    audio: >
      <audio src="soundbank://soundlibrary/home/amzn_sfx_doorbell_01"/>

Audio from local

service: script.my_notify
data:
  alexa:
    media_player: media_player.echo_dot
    message: >
      Test domain clodflrare <audio src="https://CHANGE_ME_YOUR_DOMAIN/local/comic.mp3"/>

Wait time

You can use wait_time to increase the pause between messages. Useful for long and complex templates, or for sounds.

service: script.my_notify
data:
  alexa:
    ssml: true
    wait_time: 1
    push: true
    title: Segnale Orario
    message: >
      Cucù! Sono le {{now().strftime("%H:%M")}},  accipicchia!
    audio: soundbank://soundlibrary/foley/amzn_sfx_clock_ticking_01

Media content

For now, the media content is out of the message queue. There is no way to know the duration or the end of the playback

service: script.my_notify
data:
  alexa:
    media_content_id: Alexa.GoodMorning.Play
    media_content_type: sequence
    media_player: studio, last alexa

Media content extra

service: script.my_notify
data:
  notify: false
  alexa:
    media_content_id: taylor swift
    media_content_type: AMAZON_MUSIC
    extra: 30

Notifier

service: script.my_notify
data:
  alexa:
    media_content_id: Alexa.FlashBriefing.Play
    media_content_type: sequence
    notifier: alexa_media_sala # CHANGE ME

Mode

service: script.my_notify
data:
  alexa:
    mode: "{{is_state('sun.sun', 'above_horizon')}}"
    message: >-
      message test with condition
    type: announce
    media_player: last alexa

Priority

service: script.my_notify
data:
  call_no_annuncio: true
  alexa:
    priority: true
    message: This message will always play

Event ID

automation:
  - alias: Basement light left on for 10 minutes
    trigger:
      platform: state
      entity_id: light.basement_light
      to: "on"
      for:
        minutes: 10
    action:
      - service: script.my_notify
        data:
          title: "Basement light left on"
          message: "The Basement light has been on for a long time. Do you want me to turn it off?"
          alexa:
            voice: giorgio
            event_id: "basement_light_event"
            media_player: last_alexa

  - alias: Turn off Basement light via event
    trigger:
      platform: event
      event_type: alexa_actionable_notification
      event_data:
        event_id: basement_light_event
        event_response: ResponseYes
    action:
      - service: light.turn_off
        entity_id: light.basement_light