Following on from my post yesterday I received this question:
I have an app and when I set a select field to x, I want it to stay set to x for 2 hours, then change to y which would trigger new automation.
So this is not a beginner question in my mind however here goes.
First off, you can’t schedule an automation to run exactly 2 hours later or delay one for 2 hours, and the shortest amount of time we can automatically trigger an automation to check a state is 15 mins. This means it might run up to 15 minutes later than expected. If this is important then I believe an external tool would be required to monitor the time.
Second, the follow-on automation doesn’t need to be triggered by the select field change - it can be triggered by the same automation that sets the select field to y.
Finally, as with everything I am sure there are multiple ways to achieve this. I have tried to pick one that is as simple as possible. If anyone else has an easier way then please do let us know.
First
The first thing we need to do is give something to check against so we can check if the 2hrs is up. Logically this would be a date/time field with the time set to +2hrs from the time the field was set to x. However, when using ‘before date’ searches or filters in Automations, Tape only considers the date and not the time which means that approach won’t work.
NOTE: I thought I would be able to use
current trigger date/timehowever that didn’t seem to work either. We could build a script that checks date and time if we really wanted.
However not to worry as we can really easily convert date/time into a number then we can just compare the current time with our target and if the current time is larger than the target perform the actions required.
Record
For this to work we need a field to store the Date/time in. As I said above this is actually going to be a number so a hidden number field will do.
Automation one
The automation gets triggered when the select field is changed and it adds 2hrs to the current time and then converts it to UNIX time (which is a number) and adds that to our hidden number field.
date_fns.getUnixTime(date_fns.addHours(date_fns.parseISO(current_datetime_local),2))
And this gives us a number like ![]()
Automation two
- We will use an every 15 mins trigger
- which will first create a UNIX time for the current time.
- We search for records which have the correct select field setting and have a timestamp that is a lower number than our current one.
- We then update the record/s by changing the select field and clearing the timeStamp field.
- Finally we can call our follow on automation.
Alternative
As I mentioned earlier, there are several ways to achieve this. I’ve tried to choose a simple and reliable approach. However an alternative way to do this is to wrap the bulk of the automation in a conditional so we minimise unnecessary steps:
This way we search for any records with the correct status first then only if there are any do we process further. It’s a little more complex, but probably kinder on the system. I think the added complexity is worth it.
Enhancements
Safety checks on Start
Also as single select fields it is possible to (re-set) a timer by mistake so we can build in some safety by checking for the existence of a time stamp and then checking to see if the timestamp is older than the now rather than still waiting to trigger:
As can be seen we are starting to add a fair bit of complexity now which may not be needed, however you can see the checks working here
Completed time
We can add a calculation field that displays the time the process will be completed - handy for those ‘time blind’ amongst us that will either think only 5 mins has passed and in fact it has been 5 hrs or more relevant in this case think 5hrs have passed and it’s only been 5 mins
The calculation field:
@timeStamp ? date_fns.fromUnixTime(@timeStamp) : '';
Wait time
We can add one more possible enhancement to this which is the ability to set the wait time and we can do this by adding a number field to the record and then getting it in our automation and falling back to 2hrs if it is empty:
Hopefully that gives you a clear way to handle timed transitions in Tape. It’s not perfect, but it’s practical and reliable — and as always, I’d love to hear if anyone’s found a cleaner solution.











