Replace the state with custom word

Have a rule like below. What i would like to do is replace the state word which is being read out by TTS. So instead of “on” let’s say “will light up” or instead of off “it will be dark i there”
How can that be done?

  - service: tts.google_say
    entity_id: media_player.kids_tts
    data_template:
      message: "Auto light  {{ states.automation.kids_light_auto_on.state }}"

You could use is_state(...) like this:

message: >-
  Auto light {% if is_state('automation.kids_light_auto_on','on') == 'True' %}
   will be bright
  {% elif is_state('automation.kids_light_auto_on','on') == 'False' %}
   will be dark
  {% else %}
   will be a disco
  {% endif %}
2 Likes

Nope… Get only the else condition said out

Tried to rewrite the if elif in varios ways but failed

You only get “will be a disco”?

Yup or errors. So had to go directly like below. But would love to hear if it can be done your way

message: >-
  {% if is_state('automation.kids_light_auto_on','on') %}
  Auto light  will be bright
  {% elif is_state('automation.kids_light_auto_on','on') %}
  Auto light  will be dark
  {% else %}
  Auto light  will be a disco
  {% endif %}

What if you put it in the Templates icon and try it out? It’s the fourth icon under Developer tools - the page icon with <>:

image