How to use conditions in Apilio to create smarter routines

When creating a Logicblock (a routine) with Apilio, you’ll have to define two important bits:

:arrow_right: your list of conditions: the rules that must be met
:arrow_right: your list of actions: the results you want to get

In this article we are going to see how lists of conditions are created, how you can combine your different conditions and why Apilio allows for a very powerful way of customising your home routines just how you like them.

Types of conditions

In Apilio, we have several different flavours of Conditions:

  • Time conditions:
    • time events or time frames
  • Conditions applied to Variables:
    • Boolean, string or numeric, depending on the variable they apply to

Time conditions restrict when your logic can run, for example: every Monday and Wednesday at 9AM, every day in February, between 10AM and 11AM, etc.

Conditions applied to Variables are conditions that check the status of your smart devices or services to allow you to make decisions. For example: a Variable stores whether your phone is connected to your home wifi. Your Condition then knows you are home as long as the variable says that you are connected to the wifi.

Instant (triggers) or static conditions

To execute the Actions listed in a Logicblock, every rule specified by the Conditions must be met.

Conditions can either be something that happens:

  • (in an instant :zap:) It’s 10AM:When an instant condition is met (is true), the logicblock will be evaluated and all the conditions will be checked. As this only happens in an instant, this makes it a trigger for your logicblock. These conditions are pure triggers.
  • (during a time frame :eye:) It’s between sunset and 12PM or I’m at work: these conditions stay true for a while instead of being true just in an instant, like the previous one.


You can turn a :eye: into a :zap:: When a condition is true over a period of time, in Apilio you can also transform it into a trigger. If you do this, when the condition changes (from false to true or from true to false), the logicblock will be evaluated. This is enabled by default as this works for most routines at home.

How to create a list of conditions for a logicblock

Once you have all your conditions ready, you can select the ones you want in your logicblock, you will need at least one trigger which can be a native one such as the ones highlighted with :zap: below (it can also be an external IFTTT trigger):

Combining them with the “simple AND” works for most home routines: every condition must be true for the actions to run.

If you would like to add some flexibility to your Conditions, such as “if this AND [this OR this and this]”, you can do so using complex Conditions. We have an article explaining how to set up complex Conditions here.

:bulb: Related articles

3 Likes

It’s unmodified since and modified within, not how you describe it.

1 Like

Thanks for spotting this, we’ll do a quick - ahem - edit.

Thanks a lot! :slight_smile: This is now fixed

2 Likes

A post was split to a new topic: Using Unmodified Since at the condition level?

I’ve updated this post to include the newly released time conditions :slight_smile:

And we now have two dedicated articles for the different types of conditions that I hope will be useful:

  • One for the new time conditions:
  • One for the existing conditions that are applied to variables
1 Like

I noticed something that might be helpful for others: For the Instant Triggers, they trigger an evaluation of their corresponding logic blocks both when they go from False to True (as you would expect), AND when they go from True to False (which I didn’t expect, at first). When going from False to True, the logicblock will evaluate as Negative (because that condition met since it’s not True), so your positive actions will not occur. However, you WILL see ‘evaluation of the logicblock’ on your event log. At first I was surprised to see my sunset logicblocks also evaluated at sunrise on my event log! But when I think about it, it makes perfect sense because some instant trigger conditions could be set to be required to be False instead of True, so the logicblocks need to be checked in both transition directions (F -> T and T -> F).
I hope that information will help fellow hobbyists!

2 Likes

Thanks for clarifying that :bowing_man: I’m sure it will save some of us some wasted experimentation time!

That’s an interesting feedback @K8Baldwin , thanks!
Would you welcome a setting to change this behaviour? Or would that just complicate things?

I think it’s totally fine now that I understand! Although, this is one reason why it might be nice if the event logs also included whether a logicblock evaluation was positive or negative… (so it would be easier to ignore all the times logic blocks evaluation just because my instant trigger conditions are just re-setting back to false.)

Here is a through experiment to make sure I truly understand how the instant triggers work when they flip from True to False: If you had a logicblock with 2 conditions set with condition linking as OR: 1) instant trigger condition that only became true at sunset (and became false at sunrise) 2) a static condition that was true all 24 hours of Sunday. Would that theoretical logicblock trigger and run Sundays at sunrise (and sunset everyday of coarse)? Because even though the triggering condition is false at sunrise, the static condition is True on Sundays (I guess I could make this and find out!). This would mean that the time at which you reset your instant triggering conditions back to False could still be relevant to your logic blocks. This theoretical is probably a rare situation, but I’m just enjoying myself now! :stuck_out_tongue:

1 Like

@pebneter HELP I’m out my depth!

My logic processor (aka brain) would resolve this as follows:

  • The logicblock runs every sunrise and sunset
  • It will trigger to positive actions on sunset everyday
  • It will trigger the negative actions everyday except on Sunday morning

If it would control a bulb for instance, the bulb would be on every night and the full Sunday.

Did you come to the same result? :slight_smile:

2 Likes

Thank you so much! That example helps me understand the instant triggers in greater detail! I think I totally ‘get it’ now!

3 Likes