Help setting up alexa tts card

nope, well i dont notice anything happening anyway, i tried that before and nothing happened

Using the ā€œRun Scriptā€ button should generate a debug trace if the script runs at allā€¦ Is there a trace available when you click the Trace button or does it say something like ā€œNo traces foundā€?

Also, have you tried it with the selector set to a non-Show device, just a plain Echo or Dot?

1 Like


theres this

image
and still this when i seleced a difrrent device

i also got this for the run command / ask question but i dont think this is important for the tts so i will ignore it for now
image

i had hoped it might be alexa needs to discover them so i did a discovery and it found the scipts but its defiantly within home assistant

Click ā€œTrace timelineā€ and see if thereā€™s an error and which step it is occurring at.

1 Like

image
i was going to mention in the thing it said it was turned off for some reason could it be that?

nevermind i just realised its on then off

Okay, thereā€™s something weird going onā€¦ Hereā€™s what mine looks like:

image

Notice how the entities in yours are missing their underscores and one of them does not match the script configuration you showed alexa_state vs. alexa selection.

I think it might be best to delete the script, restart HA, then re-create the script.

1 Like

ok then did a new script and noticed the id is not right so what evactly should i cangge it too

image

script.send_alexa_announcement

1 Like

ok yep i had a feeling so should i run it to test it through the script? try it through the card?

Either wayā€¦i guess through the script editor is more direct.

1 Like

still nothing it seems

and
image

ok an update the top command / ask question works on the card for all devices ā€”the tts works if run manually in the script (but only for the echo show trying to change it to the dot via the card and run tts through the script doesnā€™t happen at all) but the card is not detecting the tts script still

(i also changed it from announce to tts so no bongs before the announcemnnt)

good news i have gotten it all up and running just to figure out how to gget rid of the ā€œcall Alexa scriptā€./ play button on the bottom left

unfortunately i cant manage to sort the buttons the way i like but its cool cause it all works, except it refuses to run any groups i make i have set up a media player group with two Alexa devices but any time i run it with the group selected neither of the devices speak any ideas??

I actually had a slightly different approach: instead of a sensor, I convert an ā€œinput_selectā€ helper value to a string:

              target:
                - "{{(states('input_select.alexa_device'))|string}}"

Also I run this via an automation triggered by a button on a dashboard, and specifically checking whether I run it for a group or an individual device: for a group you have to use the ā€œannounceā€ method, while individual ones are fine with ā€œttsā€.

And adding a whisper toggle is a nice touch I think

alias: Dashboard - Alexa Says
description: ""
trigger: []
condition: []
action:
  - if:
      - condition: or
        conditions:
          - condition: state
            entity_id: input_select.alexa_device
            state: Downstairs
          - condition: state
            entity_id: input_select.alexa_device
            state: Downstairs and Basement
          - condition: state
            entity_id: input_select.alexa_device
            state: Everywhere
          - condition: state
            entity_id: input_select.alexa_device
            state: Upstairs
    then:
      - if:
          - condition: state
            entity_id: input_boolean.whisper
            state: "on"
        then:
          - service: notify.alexa_media
            data:
              target:
                - "{{(states('input_select.alexa_device'))|string}}"
              message: >-
                "<amazon:effect
                name='whispered'>{{states('input_text.alexa_says')}}</amazon:effect>"
              data:
                type: announce
                method: all
        else:
          - service: notify.alexa_media
            data:
              target:
                - "{{(states('input_select.alexa_device'))|string}}"
              message: "\"{{states('input_text.alexa_says')}}\""
              data:
                type: announce
                method: all
    else:
      - if:
          - condition: state
            entity_id: input_boolean.whisper
            state: "on"
        then:
          - service: notify.alexa_media
            data:
              target:
                - "{{(states('input_select.alexa_device'))|string}}"
              message: >-
                "<amazon:effect
                name='whispered'>{{states('input_text.alexa_says')}}</amazon:effect>"
              data:
                type: tts
                method: all
        else:
          - service: notify.alexa_media
            data:
              target:
                - "{{(states('input_select.alexa_device'))|string}}"
              message: "\"{{states('input_text.alexa_says')}}\""
              data:
                type: tts
                method: all
mode: single

1 Like

Trying to enter in the script, but I keep getting this error:

Message malformed: extra keys not allowed @ data[ā€˜send_alexa_commandā€™]

Section Iā€™m copying:

SCRIPTS -----------------------------

Most Lovelace/Dashboard Cards do not accept templates,
so the logic and templating needs to be placed in a script.
Then you can call the script from the card.

send_alexa_command:
alias: Send Alexa command
sequence:
- service: media_player.play_media
data:
entity_id: '{{ states("sensor.alexa_selector") }}'
media_content_id: '{{ states("input_text.cmd_text") }}'
media_content_type: custom
mode: single

Any suggestions?

From the information you have provided I canā€™t tell if the issue is due to where you have placed the configuration or the lack of proper indenting.

The script configurations shown in the gist are formatted for use in scripts.yaml, if you are placing them elsewhere be sure to include the top-level key script as appropriate.

The code block you have pasted is not properly formatted. The first line, send_alexa_command: should be all the way to the left. All the subsequent lines should be indented 2 spaces.

1 Like

Thanks for the reply.

I beleive the issue was that I added ā€œsend_alexa_command:ā€ to the script because as soon as I took that out it let me save.

Feel like Iā€™m so close to getting this going, but now Iā€™m running into this issue:

This entity (ā€˜sensor.alexa_selectorā€™) does not have a unique ID, therefore its settings cannot be managed from the UI. See the documentation for more detail.

I added the template sensor directly into the Configuration.yaml because I couldnā€™t figure out the settings in Helpers. Took some playing around with to not get any errors, but feels like somethingā€™s off.

Hereā€™s the code:

template:
  sensor:
    - name: "Alexa Selector"
      state: >-
        {% set room = states('input_select.alexa_state') -%}
        {% set echo_select = {
            'Kitchen Echo Show': 'media_player.kitchen_echo_show',
            'All': 'media_player.everywhere',
            'Master Bathroom Dot': 'media_player.master_bathroom_dot',
            'Kids Echo': 'media_player.kids_echo',
            'Kids Bathroom Echo': 'media_player.kid_s_bathroom_echo'
        } %}
        {%- if room in echo_select -%}
          media_player.{{ echo_select.get(room) }}
        {%- endif %}

With this code, a new Helpers entry popped up, but I canā€™t see or modify it directly from the UI (image attached).

I added the card and can see all the devices specified, but itā€™s not sounding anything.

When I give it a prompt in the first box (image attached) I get this error:

Failed to perform the action script/send_alexa_command. not a valid value for dictionary value @ data[ā€˜entity_idā€™]

What am I missing?


Make sure that the script has the correct entity ID. From the Script menu, find your script in the list and click its 3-dot expansion menu in the right column, then select ā€œInformationā€. In the pop-up, clicking the gear will open the entities settings and allow you to edit the entity ID if necessary to match what is used in the cards.

Regarding the sensor:

If you created a helper with the same name make sure to delete it and restart HA so the entity ID is available for use.

A unique_idā€¦

template:
  sensor:
    - name: "Alexa Selector"
      unique_id: any_unique_string_of_letters_and_digits_up_to_255_characters
      state: >-
        {% set room = states('input_select.alexa_state') -%}
        {% set echo_select = {
            'Kitchen Echo Show': 'kitchen_echo_show',
            'All': 'everywhere',
            'Master Bathroom Dot': 'master_bathroom_dot',
            'Kids Echo': 'kids_echo',
            'Kids Bathroom Echo': 'kid_s_bathroom_echo'
        } %}
        {%- if room in echo_select -%}
          media_player.{{ echo_select.get(room) }}
        {%- endif %}

Strangest thingā€¦ I canā€™t delete the automatic sensor that was created in Helpers and it says itā€™s Unmanageable, and every time I update the Entity ID name in Configuration.yaml to match that Sensor Entity ID in Helpers changes up a number (_2, _3, etc.).