Home Assistant automation to get thermostat temperature

Im trying to get Rhasspy to tell me what the current temperature is either upstairs or downstairs.

I have this sentence:

zone = (upstairs | downstairs) {zone}
what is [the] <zone> temperature

which triggers this HA automation:

alias: Rhasspy GetIndoorTemp
description: Rhasspy Get Indoor Temp
  - platform: event
    event_data: {}
    event_type: rhasspy_GetIndoorTemperature
condition: []
  - service: mqtt.publish
      topic: hermes/dialogueManager/endSession
      payload_template: >-
        {"sessionId": "{{trigger.event.data._intent.sessionId}}", "text" :  {%
        if trigger.event.data.zone == 'upstairs' %}
            The upstairs temperature is {{states('sensor.upstairs_temperature')}} degrees
          {% elif  trigger.event.data.zone == 'downstairs'%}
            The downstairs temperature is {{states('sensor.downstairs_temperature')}} degrees
          {% endif %} }
mode: single

But im having trouble formatting the payload_template to correctly use the Rhasspy message’s trigger.event.data.zone inside of the sensor.*****_temperature query to get the temperature value for the requested zone.

The automation runs without error, but Rhasspy does not like the test response it receives back and is unable to read out the answer. In this image the left side show the ill-formatted response, the right is a different automation response that Rhasspy likes:

The example above is one of my many attempts. I think i’m missing something about templating in HA. It’s been a challenge for me.

Thanks in advance for the help!

Try this Rhasspy - How do you reference an entities variable in an Home Assistant automation - Third party integrations - Home Assistant Community

payload_template: >-
        {% set value = 'sensor.' + trigger.event.data.zone%}
        {"sessionId": "{{trigger.event.data._intent.sessionId}}", 
"text" :  "The {{ trigger.event.data.zone_raw_event}} temperature is {{ states(value) }} degrees

You’ll need:

zone = (upstairs:upstairs_temperature | downstairs:downstairs_temperature) {zone}
what is [the] <zone> temperature

Thanks, @carkom! That worked :slight_smile: