Data_template line break, is it possible?

Is it possible to break a line in a data_template? I’ve tried everything I can think of (even reading the docs!) and now I’m just guessing. I cannot make this work in any form except by putting it all on one line which is not really very satisfactory for readability. And yes I am trying to perform addition on 5 entities, the plus sign is not one of my attempts and finding a line break character! :slight_smile:

  - service: input_number.set_value
    data_template:
      entity_id: input_number.temp_high_5day
      value: "{{ (states('input_number.temp_high_today') +
                  states('input_number.temp_high_yesterday') +
                  states('input_number.temp_high_day2') +
                  states('input_number.temp_high_day3') +
                  states('input_number.temp_high_day4')) / 5 }}"
1 Like

I just did a google search for linebreaks in jinja and it looks like you have to make a custom function for jinja. That pretty much means it’s not possible for home assistant because its unlikely that they added that in.

I only quickly looked, so maybe you could search and find another answer that may work for you.

Templating code is Jinja2.

@petro is obviously a little distracted today, come back to us brother :wink:

Multiline templates look like this…

  - service: input_number.set_value
    data_template:
      entity_id: input_number.temp_high_5day
      value: >
        {{ (states('input_number.temp_high_today') +
            states('input_number.temp_high_yesterday') +
            states('input_number.temp_high_day2') +
            states('input_number.temp_high_day3') +
            states('input_number.temp_high_day4')) / 5 }}

I wasn’t sure if that was possible with the line splits! lol

assumed it was

>
{{}}
{{}}

format and not

>
{{

}}
1 Like

:slight_smile: - You can do either, and if you want an actual line break in the output you put 2 returns (and three for a new paragraph)

This text will be on line one. 
This will still be on line one. 

This will be on a new line. 


This will start a new paragraph
1 Like

@anon43302295 thanks, that did it.

1 Like

I use the following:

         {% if is_state('sensor.ce0417142b502', 'not_home') %}
                Location: Away
                
                Distance: {{ states('sensor.phone2home') }} MIN
                
                Batt: {{ states.device_tracker.ce11171b6b04.attributes.battery|default(0) }}

But this results in one output line in my LoveLace interface

Locatie: not_home Afstand: unknown MIN Batterij: unknown

nope, white space like that is always removed.

Tnx, decided to make 3 different templates, so I can show them below each other on a picture element card.