Wild card in sentence

I have a atom mic in the office, and ESP’s in each room to detect who is where in the house, works beautifully with sending the position of people to their own sensor, for example I am.


Which plays “Andrew is in the office.” Over the office display.
And I have lots of automations that play where someone is over the speaker, using…

media_content_id: >-

But on each one the sensor.xxxcl is different so Sensor.amycl for my wife, etc etc.

What I would like to do is use a wild card.

So I have changed the sentence to …

Where is {name}

But I am not sure how to write the other side of the wild card. So far I have this, but I get “unknown” back.

media_content_id: >-

Any help would be amazing.


create a map via a variable, and get the entity id from that

    andrew: sensor.andrewcl
    wife: sensor.wifecl
  entity_id: >
    {{ names.get(slots.name | lower) }}

or if your setup is always namecl, then you can just concatinate the strings

{{ states('sensor.' ~ slots.name | lower ~ 'cl') }}

Hi, concatenation is probably going to be the way to go as I have a very strict naming convention right across the system, I have tries to add that.

media-source://tts/cloud?message={{ states('sensor.' ~ slots.name | lower ~ 'cl') }}.&language=en-IE&gender=female

Unfortunately the only reply I get it “Done”

Any ideas?


Just FYI.

Here is the trigger

platform: conversation
  - Where is {name}

And the Action

service: media_player.play_media
  entity_id: media_player.dining_room_display
  media_content_id: >-
    media-source://tts/cloud?message={{ states('sensor.' ~ slots.name | lower ~ 'cl') }}.&language=en-IE&gender=female
  media_content_type: provider
  title: Who is where.
  thumbnail: https://brands.home-assistant.io/_/cloud/logo.png
  media_class: app
  children_media_class: null
    - {}
    - media_content_type: app
      media_content_id: media-source://tts
    - media_content_type: provider
      media_content_id: >-
        media-source://tts/cloud?message={{ states('sensor.' ~ slots.name | lower ~ 'cl') }}.&language=en-IE&gender=female

I have no idea what you mean.

No worries, using the code above, I press the button on the atom and say “Where is Andrew” for example and the atom replies “done” also when I bring up assist on the dashboard I get the same thing.

But If hard code it using


Press the button on the atom and ask “where is Andrew” I get the reply “Andrew is in the office” on the dinning room display.

It’s not a huge deal breaker as there are only 5 of us in the house so I can just do an automation for each person, just thought it would be a good use of the new wildcards.

You’ll have to show the automations trace

Thank you, I am so sorry, I am very new to the whole yaml, although I am getting there, the trace says.

Error: Error rendering data template: UndefinedError: 'slots' is undefine


I hope that is right.


change slots.name to trigger.slots.name

Ok, that seems to be a step forward, now the dining room display is kicking in, but it is saying “unknow.” instead of what the sensor is reading, but I will have a play and see if I can move forward.

Thank you so much for all your help so far.

Hi there, so a slightly interesting update, yes the trigger bit was needed, but the unknow reply is being caused by the question mark Assist adds to the question. Let me break it down…

If I ask, either the Atom mic, or assist on my phone where is Andrew, it comes up as where is Andrew?

I then get a the reply unknown, and that is right as Andrew? is unknown.

If I type into assist where is Andrew with no question mark, it works perfectly.

So is there a way to strip the question mark out of the trigger slot? I know in php I can trim 1 character, is there an equivalent here?

You can replace question marks with nothing | replace('?', '')

Brilliant, thank you so much for your help.