Question on how to elegantly handle cleanup in the background from different kinds of triggers - (if that is the right way to say it) -
Scenario/Use case:
I have several automations that are called in parallel (with HA startup as the trigger) which do some ‘cleanup’ type of work. For instance there are imperfect or buggy integrations where when a call to turn something on or off fails because the connection is temporarily lost. Due to the complexity of all of the third party HA integrations this is bound to happen. For instance a timer that when it starts that is supposed to turn a light on and when finished, turn a light off. In that case because a failed call to turn the light off, the timer might not be running while the light is left on for example… So on startup I have a automations that if that light is on but the related timer is inactive (and I have that automation set as enabled), then either start the timer or turn off the light, etc.
What I would like to do is to call all of those “cleanup” automations once an hour or so, in addition to when HA starts up. So I have set up a schedule - but how to call all of those automations from the schedule? Or, should they all be changed into scripts which can then all be called from both HA startup automations and from automations triggered by schedule?
(I hate programming around other people’s bugs… It could be the most elegant way is to on a schedule to re-“call” such failed calls (for turning the light off until the light is actually off - if still applicable later), but that may be outside the scope of this discussion…)
I could make this work by duplicating the logic everywhere but just trying not to endlessly do that. Essentially I’d like to call these ‘cleanup jobs’ (for lack of a better term) from several places - thoughts?