Call a function repeatedly every x seconds

HI,
I have an app the detects a door open sensor, this is working well. However, I am trying to add the function that if the sensor is open after x seconds send a reminder. This should repeat every x seconds until the door is closed.
I sort of have it working doing the following

after I detect a sensor state change I call this

self.handle = self.run_every(self.openReminder,self.datetime(),10)

10 seconds is just for testing at the moment.
The openReminder function just writes “Still Open” to the log at the moment

the log:
2018-02-12 23:31:18.381934 INFO notify_door_open_closed_front: [‘light.study_strip_light’, ‘light.family_color_light’] has turned on
2018-02-12 23:31:18.845656 INFO notify_door_open_closed_front: Still Open
2018-02-12 23:31:27.839202 INFO notify_door_open_closed_front: Still Open

has the first call back to the openReminder function as soon as it is called, it then repeatedly calls the function every 10 seconds. I don’t want the call to happen straight away, I want it to wait the delay before calling the reminder function
Is this how it should work, I would have thought it would wait 10 seconds form the current time, then call the callback for the first time

You are telling it you want to start immediately using self.datetime() (which is the current time).

You need to add a delta to that to make it start in the future. You can do this using a timedelta object, like this:

start_time = self.datetime() + datetime.timedelta(seconds=10)
self.handle = self.run_every(self.openReminder,start_time,10)