State attr last trigger with short date

Hi

I’m using this line to display the last date an automation triggers but the outcome is way too long.

{{ state_attr(‘automation.gps_naar_gym_geweest’, ‘last_triggered’) }}

2023-08-08 13:45:22.458774+00:00

I’m only interested in the date (and time till 13:45 the rest can be removed), is that possible?

You can use strftime() to format the output however you like:

{{ (state_attr('automation.gps_naar_gym_geweest', 'last_triggered')|as_local).strftime('%Y-%m-%d %H:%M') }}

If you live somewhere that uses UTC or just want the output to be UTC, you do not need the | as_local .

1 Like