Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95919

Nested IF statements in TTS messages

$
0
0

@jeroenjoosse wrote:

After upgrading from .102 to .106, some of my templated TTS messages stopped working.

I looked through the breaking changes and found this issue, possibly the reason why it broke. But I don’t know how to fix it.

For example, this one used to work:

  - service: notify.alexa_media
    data_template:
      target: '{{ states.sensor.last_alexa.state }}'
      data:
        type: tts
      message: >
        {% if trigger.entity_id == "input_boolean.alexa_tide_report" %}
          It is
          {% if states('sensor.waterstand') | float < -40 %}
            Low
          {% elif states('sensor.waterstand') | float > 50 %}
            High
          {% else %}
            Medium
          {% endif %}
          tide.
        {% endif %}

When I remove the second and second-last line inside the tts message (“It is”, “tide.”) it works again. So I’m guessing there’s something with nested IF statements, and parts of the message not allowed inside them.

Anybody has an idea how to recreate the original message that doesn’t break templating rules? I could include the second line later, but sometimes I need to make these kind of ‘composed’ tts messages - this is just one of the simpler examples.

– edit: changed It’s to It is, just to make the code formatting look better here –

Posts: 4

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 95919

Trending Articles