Change output of value_template

Is it possible to change the output of “value_template”?
I have the google calendar-sensor integrated:

- platform: template
      sensors:
        privat:
          friendly_name: 'Privat'
          value_template: '{{ states.calendar.ABCXYZ.attributes.message}} am {{states.calendar.ABCXYZ.attributes.start_time}}'

and get the following output:

“Appointment-title” am “2017-04-23 19:00:00”

I’d like to change the date-format to:
“appointment-title” am “23.04.2017 19:00”

did you ever find a soltuion? I’m struggeling with the same issue…

maybe:
{{ states.calendar.ABCXYZ.attributes.start_time.strftime("%H:%M") }}

this didn’t work: ‘str object’ has no attribute ‘strftime’

but this did and is the most flexible I guess in case of formating:

{{ as_timestamp(states.calendar.ABCXYZ.attributes.start_time) | timestamp_custom ("%d.%m.%y", True) }}

1 Like

you can check Python format options at
https://docs.python.org/3/library/time.html#time.strftime

Hey,

I’m very sorry for not posting the solution:

The following line did solve my problem:

  value_template: '{{ states.calendar.ABCXYZ.attributes.message}} am {{ as_timestamp(states.calendar.ABCXYZ.attributes.start_time) | timestamp_custom("%d.%m.%Y, um %H:%M",True) }} Uhr.'

Cheers

2 Likes