MacroDroid does this just fine. Have to give it higher permissions and capability to run in background and never allow to sleep. Been running my security cameras macro for 2 years now with no issues.