Call a function periodically from a component

Hi,

I need to call the same function every minute from inside my component.

I want to do it using the event loop so was thinking of using async_create_task and in my function check if enough time has passed. But this doesn’t feel right and that’s why the question: is there a way to periodically call a function from a component?

Check async_track_time_interval.

Thank you, I’ll have a look

I am trying the async_track_time_interval with this simple line

hass.helpers.event.async_track_time_interval(_LOGGER.debug("triggered"), datetime.timedelta(seconds=2))

The _LOGGER is run once and after I get this error every 2 seconds

Traceback (most recent call last):
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
TypeError: 'NoneType' object is not callable

Am I passing the action right?

I was doing 2 things wrong, first not passing the hass object and second passing arguments with my function.