Add time and compare date time for input_datetime and now

Hi all,
I’m newbie. Could you please help?
I have 2 input_datetime items
input_datetime.activated_time
input_datetime.check_by_activated_time

I have 2 expectations

  1. Have an automation that triggered from 1 motion sensor
    Then, at actions will set current datetime to input_datetime.activated_time
    and set
    input_datetime.check_by_activated_time = input_datetime.activated_time + “00:15:00”

  2. Have more an automation, that check every 15 minutes
    if current time (now) > input_datetime.check_by_activated_time, it will turn off lights

Could you please help me code to do that requirements
Thank you