Value template formatting issue --need help

Hi there,
I’m trying to format the output from value template to 2 lines.
But after tried few examples, still failed.
I’d appreciate if anyone can give me a help.
Thanks

- platform: mqtt
  name: "Bus"
  state_topic: "/ha/bus"
  value_template: " {{ value_json.arrtime }} {{ value_json.arrtime608 }}"

I’ve also tried

 value_template: >-
    {{ value_json.arrtime }}
    {{- '\n' -}}
    {{ value_json.arrtime608 }}

What’s the data you’re working with, and what’s the goal?

value_template: |
    {{ value_json.arrtime }}
    
    {{ value_json.arrtime608 }}

?

Thanks for the reply.
I using Node Red to obtain Bus arriving time. Data format JSON.

msg.payload
obj
arrtime: ”854 will arriving in 3 mins”
arrtime608: ”811 will arriving in 5 mins”

If I put:
value_template: " {{ value_json.arrtime }} {{ value_json.arrtime608 }}”
Outcome will be:
854 will arriving in 3 mins 811 will
arriving in 5 mins

I want two data can show in two lines

Thanks mf, but this not work.

Thanks Thinkerer.
Replied with details.

Anyone can help?

have you tried to put both value_json’s between a single set of {{ }} ?
and added the newline/linebreak in between?

something like:

    {{ value_json.arrtime  + '\n'  +value_json.arrtime608 }}

this probably isn’t correct but gives an idea of what I mean. Cant test, because I don’t have the entities

58

or

56

Where do you want to show it on two lines?

On the States page or the Lovelace UI?

The States page ignores newlines and simply wraps the text.

Example:

  - platform: template
    sensors:
      test_newline:
        value_template: "{{ 'hello' ~ '\n' ~ 'world'}}"

States page:

Screenshot%20from%202019-07-25%2006-17-15

Template Editor:

Hi Marius,

Thanks for the reply, but it didn’t work.

Thanks Taras,

I want to show it on the states page.

You are right it just ignore newlines and wraps the text.

Btw, is there any other way to show on the Lovelace UI.

sure , you can use markdown to show any txt you like, and use line breaks :wink: