Template help!

Hi all,

I need some help getting information out of a sensor in template form. I want to have the message parts only, but I don`t know how.

This is what I have:
{{ state_attr('sensor.sl_train_status_sensor_hasl_trafik', 'events')}}

It shows all info under events.

The sensor information:
api_result: Ok
scan_interval: 300
refresh_enabled: true
attribution: Stockholms Lokaltrafik
status_icon: mdi:clock-alert-outline
events:

  • EventId: 24319
    Message: >-
    Förseningar på upp mot 30 minuter för Pendeltåg linje 40, 41 och 42X mot
    Södertälje centrum/Älvsjö/Nynäshamns centrum på grund av växelfel vid
    Häggvik.

Best regards
Thekholm

Maybe

{{ state_attr('sensor.sl_train_status_sensor_hasl_trafik', 'events')[0].Message }}

but to be sure, put {{ state_attr('sensor.sl_train_status_sensor_hasl_trafik', 'events')}} in the template debugger to see the json output

Thanks, that worked!

{{ state_attr('sensor.sl_train_status_sensor_hasl_trafik', 'events')[0].Message }}

Is also possible to display some of the message (not the hole message).

Best regards
Thekholm

The message itself is a single string.
What part on the message are you looking for?

Ok,

Sometimes the message is to long, but I can live with that.

Many thanks
Thekholm