Timing with Apilio - How to add a delay to IFTTT actions

timing
time
delay
Timing with Apilio - How to add a delay to IFTTT actions
0

#1

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 applets is something that Apilio can help you with, as it lets you orchestrate all your actions to choose their order and timings when they should be triggered from IFTTT. No coding is needed, you just need to configure Apilio and connect your IFTTT applets.

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.

Whatever your application, let’s see how you can add a delay to your IFTTT actions with Apilio.

Creating your 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.

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: If you want to know more about how to get started with Apilio, have a look at our getting started guide post.


Using Apilio to switch off hue lights triggered by Wyze Cam
#2

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?


#3

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.