Alexa TTS/Announcement from Lovelace UI and without Nabu Casa (Alexa Media Player)

Tags: #<Tag:0x00007f3263f752c8> #<Tag:0x00007f3263f75098> #<Tag:0x00007f3263f74f58> #<Tag:0x00007f3263f74e40> #<Tag:0x00007f3263f74b70>

Send a notification via the Lovelace-UI to your Alexa-Devices. You can create an elements card with an input select and a input text like shown in the picture below. You can specify if the messages should be delivered via “TTS” or “Announce” an which devices should be selectable for the notifications. No Nabu Casa or exposing your HA-Instance to the internet required.

Screenshot 2020-12-26 144026

Requirements

  • Alexa Media Player must be installed. It can be installed from the Home Assistant Community Store (HACS)
  • Input text must be created. This contains the message.
  • Input select must be created. This contains the target. The options contain the alexa devices which should be allowed to be selected to play the notification. The options can contain the friendly Name, Serial Number, entity_id, or Home Assistant Group.

How to use

  1. Select the target (or left the right one if already selected)
  2. Type the message in
  3. Hit enter! After this the automation is fired.

Blueprint:

blueprint:
  name: Alexa Media Player TTS/Announce from Lovelace UI
  description: Send a notification (TTS/Announcment) via the Lovelace-Ui with the help of a input select and input text. Uses the TTS component from Alexa Media Player which can be installed from the Home Assistant Community Store (HACS).
  domain: automation
  input:
    message:
      name: Message of the notification (Input Text)
      description: Input text where the message comes from
      selector:
        entity:
          domain: input_text
    target:
      name: Target of the notification (Input Select)
      description: The alexa device where the notification should be played. Must be in a input select. Options can be the Friendly Name, Serial Number, entity_id, or Home Assistant Group.
      selector:
        entity:
          domain: input_select
    announce:
      name: Is announcment
      description: Specify if announce-feature should be used. If not, the notification will be a standart text-to-speech.
      default: false
      selector:
        boolean:

mode: queued
max_exceeded: silent

variables:
  message_to_say: !input message
  target_for_message: !input target
  is_announce: !input announce

trigger:
  - platform: event
    event_type: state_changed
    event_data:
      entity_id: !input message

condition: []
action:
  - service: notify.alexa_media
    data:
      message: "{{ states(message_to_say) }}"
      data:
        type: >
          {% if is_announce %}
            announce
          {% else %}
            tts
          {% endif %}
      target:
        - "{{ states(target_for_message) }}"

Changelog

  • 2021-01-10: Set default value to the announce input
6 Likes

Sounds interesting, but I don’t get it…

How do you create the requirements. I have Alexa installed via HAS (and it works fine)… but the input text and input selection is a big mystery to me. When selecting them, no choices are available?

I think you forgot to set up the input text and input select. To create them via UI you have to navigate to settings --> helpers. See the next missing steps below.

  • Input text must be created. You have not to put any specifiy in, just make shure to name it properly so you can find it.
  • Input select must be created. The options contain the alexa devices which should be allowed to be selected to play the notification. The options can be named with the friendly Name, Serial Number, entity_id, or Home Assistant Group. Make shure to make this right, cause a simple misspell or something similiar can break the blueprint
  • Put the created input text and input select anywhere in your lovelace UI from where you can access it. I have done it via a elements card
  • Now set up the blueprint and make a automation with it.

If you have created the helpers, it should be pickable in the blueprint, but like above mentioned it only works right if you put the right options in the input select.

Fantastic… it works! thank you :smiley:

Edit: Sending from a desktop browser works fine… upon hitting the return/enter key, the message is sent… but I can’t seem to make them send from a mobile… pressing the return key on the mobile ‘iOS Safari’ doesn’t seem to send anything?