Google TTS, using value from sensor

Hi,

I have setup google tts and using IFTTT and webhooks have created a static commend to ask what the temperature is in my house. Google just responds with, “its cold”

Now I would like it to read the state of the samsung multipurpose sensor i have setup, HA has its setup as sensor.temperature. I have been trying to test with the service section in developer tools in HA but I am not 100% sure how to build the json. The static was easy

{"entity_id": "media_player.dining_room_speaker", "message": "it is cold"}

would someone mind helping me understand the formatting?

I have tried soemthing like

{"entity_id": "media_player.dining_room_speaker", "data_template": {"message": '{{ states.sensor.temperature.state}}' }}

This was based on some posts I read where people are doing similar configs. but I would like to bed down simple manual tasks before i start shoving config in with out understanding it.

So, you’re putting that JSON in the URL that IFTTT calls? I don’t think that’ll work. There’s nothing in that workflow that’ll interpret your state variable - I’m guessing that it is speaking the name of the variable.

You could, instead, call a script from IFTTT.

Your IFTTT URL would be something like:

https://ADDRESS/api/services/script/speak_temperature?api_password=API_PASSWORD

Then create a script:

speak_temperature:
  - service: tts.google_say
    entity_id: media_player.home
    data_template:
      message: >
        The temperature is {{states.sensor.temperature.state | int | string }}

Hi ih8gates,

No not in the URL, in the service section on HA dev tools. So i could test. but thanks to your reply i got it working perfectly and filled a gap in my understanding on HA. Really appreciate your time. Thanks a bunch

For the future could you maybe tell everyone how you got it working? It helps people that are trying to solve this themselves and are searching for answers.