Looking for advice on how to deal with dates in automations. In my current example, I have an automation that I am looking to run, and then not run again until at least 20 minutes has passed. I created a datetime helper that is reset to 20 minutes in the future from when the automation runs, and a condition within the automation that does not pass unless the current time is past what is stored in the datetime helper.
Where I run into an issue is when the date rolls over to the next day. Because the automation throws out the date portion of the helper, it just sees 20 min past when the automation was last run (say 11:30PM is stored in the helper) and therefore will never run again until its triggered after 11:30PM.
My current solution is to have another automation that automatically resets the datetime helper every day at midnight, but this seems like kind of a clunky solution. I am curious as to what others have done to rectify/get around this problem. Thanks!
What ever you’re doing to add the 20 minutes isn’t correct. Simply adding the current time + 20 minutes will cross midnight properly. I suggest you post your automation so that we can see the what you’re doing.
Also, to clarify a bit further, the time portion of this automation seems to be working fine. For example, if the automation runs on 1/29/2023 at 9:00PM, and then runs again on 1/29/2023 at 9:30PM, it passes because more than 20 minutes has elapsed between runs.
The problem occurs when the next day rolls around. For example, if the automation runs on 1/29 at 10:00PM, the helper will be set to 10:20PM. If the automation tries to run on 1/30/2023 at 8:00AM, it fails because the helper discards the date portion and only has 10:20PM stored, even though 8:00AM on 1/30/2023 is much later than 10:20PM on 1/29/2023. This issue is what I am trying to solve. Hopefully that makes sense.
as a side-node, that condition seems odd to me in general. It’s only allowed to trigger between midnight and the helper. The before in it just doesn’t make any sense.
Sounds good, thanks for the help. Yeah the visual editor makes you use the “before” condition in conjunction with the “after” condition and defaults to 00:00:00, not sure what the reasoning. I figure it works anyway because everything in one day is technically before midnight? I agree, seems weird.