I have a number of pointless sentences randomly played in different times
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.
- 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 %}