How to add a delay to IFTTT actions

Many times your IFTTT applets are just what you need for your smart applications… if you could just add a small delay to better time some of the actions.

Adding a delay to your IFTTT actions is something that Apilio can help you with. When running any automation logic, Apilio first checks a list of conditions and then runs a list of actions. You can specify a delay for each one of the actions in your list.

No coding is needed, you just need to specify the delay Apilio and connect your IFTTT applets.

Creating your list of actions (action chain) in your logicblock

When setting up your actions in your logicblock, you will add them as a list. Apilio will execute each action in the order they appear in the action chain, from top to bottom.

If there is a delay specified, Apilio will queue your actions and will fire them, one at a time, when their time comes. Delays are defined in seconds and can be any value from 0 to 3600 seconds, this is, 1 hour.

.

In this example, when the logicblock is evaluated and it determines it is time to run our positive result list of actions, it will:

  • first turn on a switch (which we signal to IFTTT via webhooks with the event turn_on_switch immediately)
  • 10 minutes later (10 minutes * 60 seconds = 600 seconds), it will turn the same switch off (which we indicate to IFTTT via the webhooks event turn_off_switch).

image

Actions are queued and delays are added up

It’s important to consider that your action’s delay starts counting down as soon as the previous action is executed. This means all your delays will add up as Apilio progresses through the queue of actions. So for example if you configure three actions:

  1. Turn on the lights (immediately)

  2. Dim the lights to 50% 10 minutes later

  3. Turn off the lights 5 minutes later

This means that: the first action will be executed immediately, the second one 10 minutes later, and the third one 5 minutes after the second one, or, adding all the delays up, 15 minutes after the first action.

Ideas that use delays with IFTTT and Apilio

You can create so many different behaviours! A few examples of these:

  • You can turn on a switch, but only for 30 minutes at a time.
  • Dim your lights progressively through 10 stages from 100% to 0%.
  • Or maybe you want to turn off all the lights in your (smart)home when leaving, but give you 10 minutes of light to find your way out safely.

What happens if I…

Add a new action when existing ones are already queued

After the logicblock has evaluated, all the existing configured actions are collected and saved for execution. If you add an action to your logicblock while the previous ones are pending, it will not be run until the next logicblock evaluation.

Delete a action when it had already been queued

If you delete an action from the logicblock configuration, and the action had already been queued but has not been executed yet, it’s execution will be skipped.

Edit an action after it had been queued

If you change a parameter value of a pending action, the last saved action configuration that was the one when the action was queued will be used. The new configuration will be used when the logicblock is evaluated again and the actions are to be run.

:bulb: Related articles

1 Like

What happens if you trigger the evaluation URL the second time before the first has finished all the actions. Does it stop the first and start the second or queue the second after the first has finished?

1 Like

This depends on whether the first action of an action chain has already started or not.
If the first action was executed, the rest of the actions will not be touched and run as scheduled. The second action chain will run independently in parallel (vs. being queued at the end of the first chain).

If the first action has not been started yet (e.g. if you have set the execution mode to “warn” or the first action has a delay), the complete old chain will be cancelled and replaced with the new one.

The reason for this behaviour is the assumption that a sequence of actions forms a bundle of actions that are meant to run through every time to make sense.

1 Like

I want to have the system notify me when my front door is open for more than 10 minutes. Currently I managed to get this working using Google Scripts. Basically IFTTT calls the script when the door opens. The script calls the Apilio door_is_open and sets it to true and the script then creates a timer-trigger that will wait for 10 minutes before calling the Apilio door_open_more_than_10_minutes variable. The logiblock will then evaulate to true (on changing variable values) and call IFTTT to send a notification. If the door is closed before 10 minutes have expired, the door_is_open variable will immediatly be set to false and the logiblock will evaluate to false and no notifications will be sent. How can I achieve this without Google scripts?

Hi Geert,
Apilio has not yet a feature to keep track of timing changes and re-evaluate logicblocks. We have that on our list, but I don’t have an ETA yet.
There are some workarounds mentioned here: Evaluation when conditions change (not variables)
A more advanced workaround is described by another community member here:
https://iused2besmart.wordpress.com/2019/09/04/using-ifttt-and-apilio-v2/

Hi Philipp,

As I mentioned earlier the ‘more advanced workaround’ you mentioned no longer works as it uses the no longer supported direct URLs for changing variable values.

I have been busy creating a new solution. In my case, I want to receive (multiple) notifications whenever my front-door (with a Nuki smart lock)
is open for more than 5 minutes. A complicating fact is that when somebody opens and closes the door within a few seconds, the triggers sometimes arrive in the wrong order (first close door trigger then open door trigger). In my solution, I, therefore, needed an extra delay action (on the close door trigger). I have documented everything in this document https://drive.google.com/open?id=1AP2qp6LFKDPwpF7euZPSrKDIxTigaHpg . I hope I can make somebody happy with this.

2 Likes

Great documentation, thanks for sharing!
We’d like to offer an in-app solution to detect “is open for more than 5 minutes”, which would make your setup a lot simpler. We are dying to for being able to work on it :cry:

1 Like