How do you reference multiple entities in a Home Assistant automation

I have Rhasspy integrated with Home Assistant and it’s working very well.
I would like to have ‘one’ automation , that tells me the temperature , be able to respond with all the different entities defined in a slot.

I have a slot setup for $Temperatures containing a list of available temperature sensors available to HA.
The Rhasspy sentence send HA the intent [GetTemperature] as an event, with the tag {entity} which would contain the ‘called for’ temperature sensor name.

I’m sure this is a HA issue, but I thought someone here might already have figured out a solution.
The issue is that I cannot find a way to evaluate the slot value of {entity} or {{trigger.event.data.entity}}, to have HA return an actual temperatures.
The statement {{states.sensor.{{trigger.event.data.entity}}.state}} is invalid,
but {{states.sensor.outside_temperature.state}} returns the temperature outside.

Any suggestion would be appreciated.

Here is my configuration:
HA version 2021.11.5
Rhasspy version 2.5.11
mqtt is external
audio recording and wake word using UDP
send Events to HA (/api/events)
HA and Rhasspy running on same Intel NUC
no satellites (yet)

sentences:

[GetTemperature]
whats the ($Temperatures) {entity} temperature 
whats the temperature ($Temperatures) {entity}
how (hot | cold) is it [in the] ($Temperatures) {entity}

slot: Temperatures

(kitchen | den | downstairs | inside):kitchen_temperature
outside:outside_temperature 
((master bath) | bathroom):masterbath_temperature
((bonus room) | (allens office)):bonusroom_temperature
bedroom:mbr_temperature

automation:

alias: RhasspyGetTemperature
description: ''
trigger:
  - platform: event
    event_type: rhasspy_GetTemperature
condition: []
action:
  - service: mqtt.publish
    data:
      topic: hermes/dialogueManager/endSession
      payload_template: >-
        {"sessionId": "{{trigger.event.data._intent.sessionId}}", "text": "the
        {{trigger.event.data.entity_raw_value}} temperature is currently
        {{states.sensor.{{trigger.event.data.entity}}.state}} degrees"}
mode: single

This should work:

alias: RhasspyGetTemperature
description: ''
trigger:
  - platform: event
    event_type: rhasspy_GetTemperature
condition: []
action:
  - service: mqtt.publish
    data:
      topic: hermes/dialogueManager/endSession
      payload_template: >-
        {% set value = 'sensor.' + trigger.event.data.entity %}
        {"sessionId": "{{trigger.event.data._intent.sessionId}}", "text": "the
        {{trigger.event.data.entity_raw_value}} temperature is currently
        {{ states(value) }} degrees"}
mode: single
1 Like

Thank you, that works great.