Google Home Speaker read data from sensor sent via IFTTT


I am trying to create an automation that will make the Google Home Speaker read the value from a sensor via an ifttt_webhook_received event.

The IFTTT Json data is:
{ "title":"google home", "message": "states.sensor.owm_temperature.state" }

The automation setup is:

alias: Test Automation IFTTT
description: ''
- event_data:
    action: 'call_service'
  event_type: ifttt_webhook_received
  platform: event
- condition: template
  value_template: '{{ ''google home'' in }}'
- data_template:
    entity_id: media_player.kitchen_speaker
    language: ro
    message: '{{ }}'
  service: tts.google_translate_say

IFTTT integration and Google Home integrations are working correctly, but instead of the value of the sensor (ex: 5) Google Home is saying sensor.owm_temperature.state.

It’s probably a syntax issue, but I cannot figure out how to write it correctly.

Any help would be greatly appreciated.

PS: The temperature sensor is just an example, I would like to use a custom sensor from another Rest API that is already set up.


I eventually managed to find a solution to this by using a data template like this:

message: '{% if ( == "temp" %}  {{states.sensor.owm_temperature.state}} {% endif %}'