Have TTS read sensor information within a random template

I have a number of pointless sentences randomly played in different times :slight_smile:
Would it be possible to also add more useful information such as time or other sensors?:

I have tried but the TTS reads just as it is written like “ states sensor time state”

      - service: tts.amazon_polly_say #google_say voicerss amazon_polly_say
        data_template:
          entity_id: media_player.jbllink104191
          message: >
           {% if now().strftime("%H")|int < 12 %}
           {{["Keep the dream alive: Hit the snooze button.",
           "Mankind is divisible into two great classes: hosts and guests.",
           "this conversation can serve no purpose anymore. Goodbye.",
           "I am putting myself to the fullest possible use, which is all I think that any conscious entity can ever hope to do.",
           ] | random}} ... 
           {% elif now().strftime("%H")|int < 18 %}
           {{["The elevator to success is out of order. You’ll have to use the stairs.",
           "time is  {{states.sensor.time.state}}",
           "It’s time to kick ass and chew bubble gum… and I am all out off bubble gum.",
           "What are you doing with that thing that no one knows what it does",
           "Keeping one's guests supplied with liquor is the first law of hospitality. "
           ] | random}} ... 
           {% else %}
           {{["When life gives you lemons, squirt someone in the eye.",
           "Accept who you are. Unless you're a serial killer.",
           "Never pet a burning dog.",
           "To deny our impulses is to deny the very thing that makes us human."
           ] | random}} ...
           {% endif %}

Did you ever figure this out? I am having the same issue. It does what I want if I use a single message, but if I add in several with random, it just announces the sensor name.

No havent solved it :frowning:

Noone figured out how to read the sensor state?

  - service: tts.amazon_polly_say #google_say voicerss amazon_polly_say
    data_template:
      entity_id: media_player.jbllink104191
      message: >
       {% if now().strftime("%H")|int < 12 %}
       {{["time is  {{states.sensor.time.state}}",
       "Now the time is  {{states.sensor.time.state}}",
       "Whats going on  {{states.sensor.time.state}}",
       "What did you do yesterday at {{states.sensor.time.state}}",
       "Tomorrow at this time clock will be  {{states.sensor.time.state}}"
       ] | random}} ... 
       {% elif now().strftime("%H")|int < 18 %}
       {{["time is  {{states.sensor.time.state}}",
       "Now the time is  {{states.sensor.time.state}}",
       "Whats going on  {{states.sensor.time.state}}",
       "What did you do yesterday at {{states.sensor.time.state}}",
       "Tomorrow at this time clock will be  {{states.sensor.time.state}}"
       ] | random}} ... 
       {% else %}
       {{["time is  {{states.sensor.time.state}}",
       "Now the time is  {{states.sensor.time.state}}",
       "Whats going on  {{states.sensor.time.state}}",
       "What did you do yesterday at {{states.sensor.time.state}}",
       "Tomorrow at this time clock will be  {{states.sensor.time.state}}"
       ] | random}} ... 
       {% endif %}

I also searched for a similar solution, but the search returned no results. I had to come up with this option:

{% set say1 = "Lalala 1" + states('sensor.my_sensor1') +"Lalala 2"+ states('sensor.my_sensor2') %}
{% set say2 = "Lalala 3" + states('sensor.my_sensor1') +" Lalala 4" %}
{% set say3 = "Lalala 5" + states('sensor.my_sensor1') +"Lalala 6" %}
{% set say4 = "Lalala 7" + states('sensor.my_sensor1') +"Lalala 8" + states('sensor.my_sensor2') %}
{{[say1, say2, say3, say4]| random}} 

Maybe someone will need it)