How to set up smart home control via IFTTT and save money



It always seemed to me that the main thing in a “smart home” is not even the capabilities of a particular device, but the ability of these devices to interact with each other, realizing complex scenarios. To do this, it is no longer necessary to be limited to components from one manufacturer, since there are aggregators, like Google Home or Alice's device management skills. However, some scenarios are still beyond their power. Today we'll talk about how to get around this using IFTTT - a universal intermediary between web services. And spoiler: I'll mention at the end how to get around the limitations of IFTTT itself.



IFTTT in a nutshell



The IFTTT mashup service is about 10 years old, so it doesn't need a detailed introduction. IFTTT helps interconnect internet services that are not directly integrated. Instead of working out a dozen different integrations, the creators of the Internet service just need to integrate with one IFTTT, which becomes a universal intermediary, allowing end users to determine the direction of data transfer to the side and the tasks that the integration solves.



IFTTT is often remembered in the context of automatic reposts from one social network to another. It is also easy to use for gathering useful information and tasks. For example, working in different teams, each with a different task distribution tool, I aggregate everything that is assigned to me in different systems - Trello, Asana and email - into my personal Remember the milk (RTM).





RTM itself has some integrations with third-party services, but they are only available in the paid version. So IFTTT made it possible to bypass the need for a paid subscription. At the same time, I helped set up a Telegram bot to quickly add tasks from the messenger.









IFTTT doesn't just live in the virtual world. If the components of the smart home or any other IoT devices have access to the cloud (and the manufacturer has integrated their web service with IFTTT), you will be able to control them through the IFTTT applets.



Of course, there are a lot of reservations here. Scenarios can only be extremely simple - "if - then", no complex logic. The service understands the Cyrillic alphabet in the names of applets and text fields when configuring them, but not all functions work in Russia and with the Russian language. For example, in the United States, users have the opportunity to create a script that calls a mobile phone upon some event. This feature is not available outside the States. Also, many popular Russian resources (from VKontakte to Alice) are not integrated with IFTTT.



But today we will not be talking about that, but about how IFTTT helps to work with devices. Most of the smart home components available in our market are produced outside our country and rely on foreign web services, and IFTTT is popular among them.



Controlling smart devices using Sonoff as an example



IFTTT is integrated with a wide variety of smart home systems. Components of several of them are sold in Russia, but Sonoff (eWeLink Smart Home system) subjectively seems to be one of the most popular, mainly due to the price (you can buy Wi-Fi relays on sales on AliExpress for 300-400 rubles).



What are Sonoff devices?





Sonoff is a brand of affordable Wi-Fi controlled relays, outlets, sensors and switches. System components can be purchased in the Russian Federation or ordered from China. They are well known on Habré due to the fact that the craftsmen are flashing the ESP8266 Wi-Fi module used in them so that devices do not try to access the cloud on Amazon, but work inside the local network (replacing the cloud service with their own smart home hub). But to work with IFTTT, such a flashing is just not needed.



Out of the box, device control is carried out from a smartphone from the eWeLink application (in theory, there is a web interface, but it is in the initial stage of development).



In the past few years, the service of the same name has been improved. Integration with Google Home and Alice has appeared, so that devices can even be controlled by voice in Russian without any complicated settings. However, some scenarios cannot be implemented only in the application. For example, by installing a relay with a temperature and humidity sensor on a warm floor, it will not be possible to create a complex scenario in the application that allows you to turn on or off the heating according to the data of both sensors.



Although the set of commands is still limited, the application already allows for various interesting scenarios. For example, you can turn on and off a night light in a room in accordance with the schedule of sunrises and sunsets for a specific day (the function is configured once, and every day the switching time of the night light changes slightly in accordance with astronomical data).



At the same time, the application perfectly copes with the task of turning off devices at night on a schedule, with settings for cyclic timers and does many other useful, but not very smart things.



We connect eWeLink to IFTTT



When setting up a smart home, the need for IFTTT appears at the moment when you want to implement a scenario that is not supported by the manufacturer (for example, by grouping devices), or to combine several functions from different manufacturers into a single whole. Unfortunately, in the latest version of the eWeLink application, the manufacturer decided to make money on those who do not have enough simple scripts, and opens the integration with IFTTT only on a paid plan - $ 9.99 with PayPal payment per year. This is not such a large amount for a year-long experiment.



Why an experiment? Because the real convenience of certain scenarios is shown only by long-term daily use. Smart devices have been living in our apartment and replacing each other for more than one year. When a new component appears, a dozen scenarios are already twisted in my head, which it will allow to implement. And at first everyone is involved. But after a month, 9 out of 10 are no longer used. And the one that “survives” undergoes some changes - during this time the idea is “fine-tuned” for itself: how long should the light in the hallway continue to burn after the button is pressed? What level of brightness should the night light in the hallway have? What thresholds for sensor readings must be set to send notifications so that they do not strain, etc.



IFTTT allows you to implement a lot of scenarios and easily reconfigure them. To illustrate the approach, let's assume that we want to automatically turn off the thermo-pot when I leave the house farther than the next street. This can be done in an elementary way:





Create a new applet (Create). As a trigger (+ This), select the Location service, which takes the location from an Android device (or iPhone) where the IFTTT client is installed (logged in under the same account, if you set up a script in the web interface).







There are 3 triggers available for the service. "You exit area" will suit us.





Set the address of the central point of the zone and the radius around this address (the radius is regulated by increasing / decreasing the map scale). IFTTT was pleasantly surprised by the fact that it understands the input of the address in Cyrillic. Unfortunately, the radius cannot be too large - for example, an entire million-plus city cannot be designated as a zone.





We create a trigger in this way (the Create trigger button at the bottom of the screen).





We set the action (+ That) - disable the eWeLink relay. To do this, we connect the eWeLink Smart Home service. After clicking on Connect, you will need to log in to your eWeLink account in a separate window.











If authorization is successful, a whole list of available actions for eWeLink Smart Home will appear.





Click "Turn 1-Channel Switch on or off" and on the next page from the drop-down list select the desired device, as well as the required state (on or off). In my case, it is the relay that is used to connect the thermopot, and not the socket, but if you make a mistake and select “Turn 1-Channel Plug on or off”, nothing will break.





Create an action with the Create action button and complete the applet setup.





A more difficult task is to implement a bot in Telegram to "communicate" with the house. To do this, you need to connect the Telegram service. By creating the appropriate applets, you can add commands to the bot to control devices (turning on / off lights and individual devices), and at the same time various useful notifications, in particular:



  • . — . Google , IFTTT, .
  • , / / . . , ( ). . , .
  • , - ( ).


Let's create an applet that, on a command from the Telegram chat, turns on the night lights in the corridor (like the thermo-pot connected via the Sonoff relay). Let's start by connecting the Telegram service. Let's find it through Explore (Services tab):







Click Connect to connect it to your account. After the invitation, go to Telegram and add the bot to contacts.







Click Start to log in.





After switching to IFTTT for authorization, we have access to all the possibilities of communication between the service and the messenger.





Now go back to IFTTT and start creating the applet.





Select Telegram as the trigger.





The trigger "New message with key phrase to @IFTTT" is suitable for us.





Let the key phrase be "night light", and the answer to my message - one word "Turn on" (remember that the service is sensitive to lowercase / uppercase letters).





Let's move on to setting up the action.





As in the previous example, we choose to enable the relay of the eWeLink Smart Home service. This time, only in the list of devices you need to select what corresponds to the backlight.





With notifications, everything works the same, only some other service (for example, a sensor from eWeLink Smart Home) will act as a trigger, and the action will be performed by Telegram - sending a message of certain content.



As mentioned above, in the smart home segment, IFTTT is not limited to supporting only Sonoff devices - this is just an example at hand. There are a lot of manufacturers who have already integrated with the service, and even more user advice on how to get around the lack of integration, for example, with Xiaomi Mi Home (spoiler - via notifications on a mobile device for Android).



When IFTTT is not enough



The logic behind IFTTT is pretty simple: one condition, one action. Interesting things can be done on the basis of this logic, but sooner or later this becomes insufficient. Unfortunately, the service does not allow specifying chains of actions (for each of them, you will have to create your own script), just as it does not allow you to build complex conditions consisting of several parts with a logical “and” or “or”.



But this can also be circumvented with the help of an "add-on". We are talking about the apilio.com service , whose task is to add more complex logic to IFTTT. Connecting an additional tool, of course, will be another level of system complication, but it will bring the setting of smart home scripts closer to programming - you can set variables, change their values ​​when triggers are triggered, construct conditions, etc.



Let me show you what Apilio can do, using the example of complicating the scenario with disabling the thermal pot.

Initially, the thermo-sweat relay is turned off at night (from 2 am to 8 am) and when I leave the zone set in IFTTT. But what if someone else lives at home besides me? Agree, it will be inconvenient if the water heating turns off every time I leave for work. It is more logical to just remind that the thermo-pot is on if I am not at home at a certain time (at the moment the thermo-pot is turned on after "sleeping at night") - after thinking over the scenario, it seemed to me that this is the best indicator that I have gone somewhere for a long time.



For this:



  • We register on the Apilio service;
  • Create 2 boolean variables that are false by default (let's call them location and teapot);






  • : I_exit_area ( true, IFTTT ) I_forgot_teapot (true, );






  • Apilio IFTTT. IFTTT Webhook Apilio, IFTTT ( — URL, “”). IFTTT Apilio;




  • IFTTT location teapot ( eWeLink Location, — true Apilio, «Update a variable in Apilio to true»);










  • : IFTTT ;




  • IFTTT ( Apilio, — Telegram ).


Result: if something makes the thermopot turn on at the moment when I am far from home, I will receive a question in Telegram: “Did you forget to turn off the kettle?”



In the free version, the Apilio service allows you to specify one logical scheme and this is enough for an experiment. Annual subscriptions start at $ 7.2, which is also quite affordable. Like IFTTT itself, the service already has a lot of analogues - I think you can pick up something free for your tasks. It is only important to understand that by opening access to a new service to your smart home, you in some sense share personal data with it - so security is not the last issue here.



The development of IFTTT, Apilio and similar tools shows that smart home users still have a need for some kind of complication of scenarios. No matter how many manufacturers fight for maximum simplification, sometimes without additional logic in any way.






All Articles