Calendar event - strftime current time +1 minute

Hey, I’ve got an automation and part of it is as follows:
end_date_time: "{{ now().strftime(\"%Y-%m-%dT%H:%M:%S\") }}"

This sets the end time of a calendar event to the current time/date. However, what I’d like to do is alter it so it’s + 1 minute from the current time.

How might I achieve this?

Many Thanks

end_date_time: "{{ (now() + timedelta(minutes=1)).isoformat() }}"

That code doesn’t appear to work when I substitue it out for what I had above resulting in the following:

service: calendar.create_event
  summary: "Event"
  start_date_time: "{{ now().strftime(\"%Y-%m-%dT%H:%M:%S\") }}"
  end_date_time: "{{ (now() + timedelta(minutes=1)).isoformat() }}"

Error parsing event input fields

Try working on the expression is developer tools / templates. Easier to iterate and see what may be going wrong.

Putting just this into developer tools / templates appear to return no errors

{{ (now() + timedelta(minutes=1)).isoformat() }}


Result type: string


This template updates at the start of each minute.

So perhaps it doesn’t work within an automation for another reason?

Is it because it’s returning this at the end:


When I only need:


Not sure how I would get that result?

In your automation you are using “ to quote the string and “ within the string. Change those inner ones to single quotes and it’ll start loading.

This was tested and confirmed to work:

service: calendar.create_event
  summary: "Event"
  start_date_time: "{{ now() }}"
  end_date_time: "{{ now() + timedelta(minutes=1) }}"

This worked perfectly, thank you.

1 Like