Dropdown menu to select speaker?

Is it possible to create a dropdown helper with a list of some of my speakers (google) that shows their friendly name and then I can use that helper for tts? I can use the UI to create a dropdown helper but if I use the speakers’ friendly names I don’t know how to transform that into an entity_id so i can use it with tts.

image

A ‘quick-and-dirty’ approach would be to use entity_id’s that can be derived from the friendly names. In order to do so you can apply the slugify filter:

https://github.com/home-assistant/core/pull/58724

Although this essentially amounts to guessing, it might work for you. Otherwise you need to loop over the speakers and compare names to retrieve the entity_id.

I use the following to select between my Alexa’s so I have a central place I can quickly do tts or type in commands if I want to:

With more recent additions to templating you may be able to acheive something similar without manually creating the mapper/dictionary, but still relatively efficiently compared to other methods. In this case, the options for the Input select needs to match the name of the entity. I don’t use Google home so I can’t tell you exactly what will be needed as your filter. For Alexa devices it would look something like the following In a script…

variables:
  target: >
    {% set x = states('input_select.alexa_state') %}
    {{ expand(integration_entities('alexa_media'))
    | selectattr('name', 'eq', x)
    | map(attribute='entity_id') | join() }}
sequence:
  -  service: notify.notify
     data:
       message: The garage door has been open for 10 minutes.
       target: '{{ target }}'
1 Like

Thanks. I can get things to work inside the developer tools but when I try to put it all together inside a card I cannot get it to work. This is the code that I wrote:

type: entities
entities:
  - entity: input_select.announcement_speaker
  - entity: input_text.announcement_text
    type: custom:text-input-row
    name: Message
  - type: call-service
    name: ' '
    icon: mdi:voice
    action_name: Announce It...
    service: tts.google_say
    data_template:
      message: '{{ states(''input_text.announcement_text'') }}'
      entity_id: '{{ states(''input_text.announcement_speaker'') }}'

image

When I click Announce it i get the following error

Failed to call service tts/google_say. required key not provided @ data['entity_id']

Most dashboard cards do not accept templates… that is why, in the provided example, the call service in the card fires a script and the script handles the logic and templates.

Did this ever get solved for Google Mini?