Correctly adding time segments

Tags: #<Tag:0x00007f73ac5a2658> #<Tag:0x00007f73ac5a2220>

I have an automation that should set a datetime varaible to 15 minutes into the future. This is my current action.

  - service: input_datetime.set_datetime
      entity_id: input_datetime.future_date
      date: '{{ (as_timestamp(now()) | timestamp_custom("%Y-%m-%d", true)) }}'
      time: '{{ (as_timestamp(now().replace(minute=(now().minute+15))) | timestamp_custom("%H:%M:%S", true)) }}'

This approach is prone to errors because adding 15 to a minute value over 45 will end up in out-of-range value, so I was hoping there would be some other approach like now().addminutes(15) or something like that. Any ideas how to make this more solid?

Change it to seconds, add 15 * 60.
It will also work across dates…