Add 30 minutes to last triggered

Hi,
This template gives me the time when then automation was last trigged. Can I add 30 minutes to that time?

{{ as_timestamp(states.automation.openepaper_el.last_changed)| timestamp_custom('%H:%M') }}

Well you’re working with timestamps (seconds since epoch) so just add 30x60 = 1800

{{ (1800 + as_timestamp(states.automation.openepaper_el.last_changed)) | timestamp_custom('%H:%M') }}

1 Like

Your topic’s title asks to add 30 minutes to last triggered but your template references the last_changed property. Which one do you actually want because they’re not the same.

This is the last time the automation was triggered:

{{ state_attr('automation.openepaper_el', 'last_triggered') }}

Here’s one way to add 30 minutes to it.

{{ ((state_attr('automation.openepaper_el', 'last_triggered') + timedelta(minutes=30)) | as_local).strftime('%H:%M') }}

Here are two more ways.

{{ ((state_attr('automation.openepaper_el', 'last_triggered') + timedelta(minutes=30)).timestamp()) | timestamp_custom('%H:%M') }}
{{ (state_attr('automation.openepaper_el', 'last_triggered') + timedelta(minutes=30)) | as_timestamp() | timestamp_custom('%H:%M') }}
2 Likes