This started out as a query in another thread however after finding a solution that I like I thought the solution itself was worthy of its own thread as it has much broader home automation application than my single light scenario.
I'm sure many of you use or have tried IFTTT, and while it can connect to a seemingly unlimited number of services, the control logic is a little, well, lacking shall we say. Basically you have input events (triggers) that can then be connected to an action. Some services provide both triggers and actions, some only one or the other.
So you could have a trigger that says when I enter this area (geofencing) perform that action. (turn on my light) But what if you want to add other conditions such as only turn on the light if its night time when you enter the area ? Sorry, can't do it, even if you have another set of triggers that fire for sunset and sunrise. There is no way to combine different triggers as there is no persistent state that can be shared between triggers, nor any way to cascade or link triggers together or perform logical actions like AND or OR. These and other limitations are very surprising to me, and for many purposes make IFTTT pretty useless.
However I found a solution that so far, works very well: https://apilio.com/
This is a free 3rd party service that integrates with IFTTT like any other service provider which provides what I would call "logic middleware". You can create persistent bool/string/numeric variables that can save and accrue state based on triggers being sent to it from other IFTTT services, those variables can be used to create conditions, and those conditions can then be used in logic blocks where you can define an arbitrary set of logical conditions before performing or not performing actions. Those actions then send events back to IFTTT that can then be connected to other services to perform actions such as turn on a light.
Actual logic block execution/evaluation can either be initiated by an IFTTT trigger directly, or automatically execute when any of the variable conditions changes. More on that later.
One thing I should note is that prior to October 2019 Apilio relied on the Webhooks API in IFTTT and wasn't directly integrated so many of the posts in their support forum revolve around this now obsolete connection method which I found confusing at first, so if you are browsing their forum or documentation keep in mind that Webhooks aren't needed and are obsolete now, just add it as any other service directly in IFTTT, and you don't need to do anything with the "IFTTT Webhooks Service API Key" in your Apilio account.
I'll use my own light scenario as a tutorial of how Apilio could be used. I have the following criteria for my porch light:
1) Turn on at 7am Monday to Friday, but only if I am home, and only if it's dark outside... and set a timer to turn it off again one hour later in case I don't leave the house that day (holiday) and forget to turn it off manually.
2) Turn off once my phone leaves a 1km radius of the house, regardless of whether it's light or dark outside.
3) Turn on when my phone comes back within a 1km radius of the house, but only if it's dark outside, and set a timer to turn it off again 10 minutes later.
Fairly simple logical conditions but as far as I can see totally impossible to achieve natively in IFTTT. So enter Apilio.
First we need two pieces of persistent state information that automatically update - am I at home, and is it daytime. So first I create two variables in apilio called "at_home" and "daytime":
I can then update these from IFTTT using triggers. Apilio actually provide sample applets for both of these although you can create your own custom ones. One is the "When I enter an area, update a variable in Apilio to true" applet - I select my location and a radius around it (I used about 1km) and then tell it to assign this to the Apilio variable "at_home". I then do the same with another applet with the same location radius to set the variable to false when I leave the area.
For daytime they have an applet "Set a variable in Apilio to true on sunrise" which also takes my location and I tell it to update the "daytime" variable, and likewise one that sets the variable to false on sunset. (I think Weather Underground is the source of the sunrise/sunset time) Now we have two variables that are updated in real time when sunrise and sunset occur or when I leave or arrive home.
From those variables we can now create conditions that can later be tested, and I have the following conditions defined:
At_Home = "at_home" must be true.
Daytime = "daytime" must be true.
Nighttime = "daytime" must be false.
Leaving_Home and Arriving_Home are interesting because they are not state conditions but state change conditions. This is done by specifying a "modified within" period:
This means that the condition Arriving_Home is only true for 60 seconds after the variable at_home changes from false to true, and then becomes false again after this.
[Continued next post due to the silly forum limit of 4 images per post...]
I'm sure many of you use or have tried IFTTT, and while it can connect to a seemingly unlimited number of services, the control logic is a little, well, lacking shall we say. Basically you have input events (triggers) that can then be connected to an action. Some services provide both triggers and actions, some only one or the other.
So you could have a trigger that says when I enter this area (geofencing) perform that action. (turn on my light) But what if you want to add other conditions such as only turn on the light if its night time when you enter the area ? Sorry, can't do it, even if you have another set of triggers that fire for sunset and sunrise. There is no way to combine different triggers as there is no persistent state that can be shared between triggers, nor any way to cascade or link triggers together or perform logical actions like AND or OR. These and other limitations are very surprising to me, and for many purposes make IFTTT pretty useless.
However I found a solution that so far, works very well: https://apilio.com/
This is a free 3rd party service that integrates with IFTTT like any other service provider which provides what I would call "logic middleware". You can create persistent bool/string/numeric variables that can save and accrue state based on triggers being sent to it from other IFTTT services, those variables can be used to create conditions, and those conditions can then be used in logic blocks where you can define an arbitrary set of logical conditions before performing or not performing actions. Those actions then send events back to IFTTT that can then be connected to other services to perform actions such as turn on a light.
Actual logic block execution/evaluation can either be initiated by an IFTTT trigger directly, or automatically execute when any of the variable conditions changes. More on that later.
One thing I should note is that prior to October 2019 Apilio relied on the Webhooks API in IFTTT and wasn't directly integrated so many of the posts in their support forum revolve around this now obsolete connection method which I found confusing at first, so if you are browsing their forum or documentation keep in mind that Webhooks aren't needed and are obsolete now, just add it as any other service directly in IFTTT, and you don't need to do anything with the "IFTTT Webhooks Service API Key" in your Apilio account.
I'll use my own light scenario as a tutorial of how Apilio could be used. I have the following criteria for my porch light:
1) Turn on at 7am Monday to Friday, but only if I am home, and only if it's dark outside... and set a timer to turn it off again one hour later in case I don't leave the house that day (holiday) and forget to turn it off manually.
2) Turn off once my phone leaves a 1km radius of the house, regardless of whether it's light or dark outside.
3) Turn on when my phone comes back within a 1km radius of the house, but only if it's dark outside, and set a timer to turn it off again 10 minutes later.
Fairly simple logical conditions but as far as I can see totally impossible to achieve natively in IFTTT. So enter Apilio.
First we need two pieces of persistent state information that automatically update - am I at home, and is it daytime. So first I create two variables in apilio called "at_home" and "daytime":
I can then update these from IFTTT using triggers. Apilio actually provide sample applets for both of these although you can create your own custom ones. One is the "When I enter an area, update a variable in Apilio to true" applet - I select my location and a radius around it (I used about 1km) and then tell it to assign this to the Apilio variable "at_home". I then do the same with another applet with the same location radius to set the variable to false when I leave the area.
For daytime they have an applet "Set a variable in Apilio to true on sunrise" which also takes my location and I tell it to update the "daytime" variable, and likewise one that sets the variable to false on sunset. (I think Weather Underground is the source of the sunrise/sunset time) Now we have two variables that are updated in real time when sunrise and sunset occur or when I leave or arrive home.
From those variables we can now create conditions that can later be tested, and I have the following conditions defined:
At_Home = "at_home" must be true.
Daytime = "daytime" must be true.
Nighttime = "daytime" must be false.
Leaving_Home and Arriving_Home are interesting because they are not state conditions but state change conditions. This is done by specifying a "modified within" period:
This means that the condition Arriving_Home is only true for 60 seconds after the variable at_home changes from false to true, and then becomes false again after this.
[Continued next post due to the silly forum limit of 4 images per post...]
Comment