Getting started - an introduction to Apilio

conditions
variables
action
logicblock
Getting started - an introduction to Apilio
0

#1

Apilio in a nutshell

Apilio allows you to build custom logic for your smart home or any smart automation. It’s a great complement to IFTTT: with Apilio you can daisy-chain applets to create automations that have more than one trigger condition and/or multiple actions, no coding required.

The four key concepts of Apilio

There are four concepts to master in Apilio: logicblocks, variables, conditions and actions:

  • Variables store states
  • Conditions check the state of a variable
  • Logicblocks define the logic for your automation and only if the selected conditions are met one or more actions are triggered in IFTTT as a result

Logicblocks are where you set the logic you want your automation to follow: you will define which conditions must be evaluated to determine which actions must happen. For example: "if the humidity level is above 90%, turn on a dehumidifier" represents a conceptual logicblock. "if the humidity level is above 90%" represents the condition, in this case, of a numeric variable, and "turn on a dehumidifier" represents the action.

Let’s take a look at the conditions and the variables first.

Conditions will check if they match a variable state (they are true) or they don’t (they are false). The true/false result depends on the variable type.

There are three types of variables you can use: numeric, string and boolean.

  • Boolean variables are used to store “true/false” (“yes/no”, “on/off”) information. Useful for example to store whether it is daytime or nighttime, or if I’m at home or not.
  • Numeric variables are used to store numbers, such as the temperature or humidity level or the number of astronauts in space.
  • String variables are used to store text, like "New York" or “snow”.

We apply conditions to our variables so we can then use them within logicblock expressions. Conditions can only result in either true or false. For example, the boolean variable ‘Nighttime’ can only be true or false, and if we have a condition to check whether it is nighttime, this condition can only result in true (when it is nighttime) or false (during daytime).)

:bulb: If you want to learn in detail how Apilio determines the value of a condition, have a look at this article on conditions in Apilio.

Once you have your conditions setup, you can use these in a logicblock and run your actions.

A logicblock will check if all the selected conditions are true, and then send to IFTTT the events specified so you can trigger your actions. Actions, as you can see, are simply events that Apilio sends to IFTTT to signal it is time to trigger a specific action. An example of an action would be "turn on a dehumidifier”. You can create an applet in IFTTT that awaits to receive this Apilio event, to then tell your smart humidifier it is time to start functioning.

Putting it all together in an example

Imagine you want to automate that when you are no longer home during the day, your living room lamp and fan are turned off to save energy. These are the building blocks to achieve this example:

The variable: We will use a boolean variable to store whether it is daytime or not.

With an IFTTT applet, I will set the ‘daytime’ variable to true at sunrise, using the Weather Underground service in IFTTT, and set it back to false at sunset with a second applet.

The condition: My condition will check if the “daytime” variable is true, as we want to control our lamp and fan when it is daytime.

The logicblock: My logicblock will be evaluated when I’m no longer home. Whenever I disconnect from my home WiFi, an IFTTT applet will evaluate my logicblock – that is, the applet’s action is to tell my logicblock to check whether its other conditions are met.

My condition will check if it’s daytime. When I evaluate my logicblock (when I disconnect from my home wifi), I will check if it is daytime and, if it is, I will send the event “turn everything off” to IFTTT.

The actions: Both my lamp and my fan are connected to a smart plug that I can control from IFTTT. When IFTTT receives the event “turn everything off” from Apilio, then I will turn this smart plug off.

You can find examples to get you inspired here. And let us know your comments and questions below, all welcome :slightly_smiling_face:


Getting started with Apilio and IFTTT
Timing with Apilio - How to add a delay to IFTTT actions