How delays work in Apilio in detail

You’ll find that many times your smart home setup is just what you need… if you could just add a small delay to better time some of the actions.

Adding a delay to your 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 in Apilio and connect your IFTTT applets, your Tuya or Philips Hue actions. You can even add delays to webhook actions!

Let’s see how this is done.

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 actions 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

2 Likes