integration with the ifttt - integration with the ifttt the ifttt (ang. if this then that)...

Download Integration with the IFTTT - Integration with the IFTTT The IFTTT (ang. If This Then That) offers plenty

Post on 28-May-2020

0 views

Category:

Documents

0 download

Embed Size (px)

TRANSCRIPT

  • Integration with the IFTTT The IFTTT (ang. If This Then That) offers plenty of useful applets, that allows to automate daily routines by creating simple logic rules. The webhooks applet paid our special atten- tion. What is the functionality of this applet? It’s really impressive! Based on the we- bhooks applet, the DOMIQ has been opened up to a whole new dimension of integration. This applet allows to send HTTP requests from the Base module to the IFTTT server and thus run created applets. There is also reversed functionality - the applet can send a HTTP request to the Base module and in result invoke any event. How does this affect Base functonality? Let's just list a few of the most interesting features and new arrivals are still coming up: • Invoking events in the Base module based on location of your mobile device. • Integration with new devices, such as Philips Hue, Amazon Alexa, Nest thermostat and

    many more. • Integration with Google account, for example exporting any data available in the Base

    module to a spreadsheet, sending emails based on smart home events. • Invoking events in the Base based on weather information. • Integration with native functionality of the iOS/Android (calendar, contacts) • Integration with Skype - sending messages as reaction to events in the DOMIQ

    system. In this tutorial we will present how to send requests to the IFTTT server in order to trigger created applet. We will also show how to handle request sent from the IFTTT server. NOTE! Software version 1.9.0.1 or newer is required to realize funcitonality presented in this tutorial.

    1. Integration with the IFTTT in the DOMIQ As mentioned in the introduction, integration with the IFTTT is bi-directional. Base can re- ceive requests sent by IFTTT and also can send requests to the IFTTT server.

    1.1. Sending request to the IFTTT server For this purpose we created a new identifier with the following syntax: IFTTT=ap- plet_name?optional_data. As the applet_name, pass the name of the IFTTT applet to be called.The optio- nal_data part as name suggest is optional and can be omitted if the applet does not re- quire any additional data. Based on the data provided, Base will automatically create and send a HTTP request to the IFTTT server.

    Integration with IFTTT www.domiq.eu

    © DOMIQ 2017 Page 1 z 13 TU-0024-EN-170928

  • • C.IFTTT=tester This command will invoke the IFTTT applet called tester.

    • C.IFTTT=temperature?value1=24.5 This command will invoke the IFTTT applet called temperature and will pass additional parameter value1 with value 24.5

    1.2. Receiving HTTP requests from the IFTTT To receive HTTP requests from the IFTTT server, public IP address is required. If you only have a dynamic public IP address, then use dynamic DNS. You’ll also need to redirect port in router settings to point local IP address of your Base module and port number that matches value of the Web Port parameter (default is 80) set in Base’s configuration (the Settings tab). Requests received from the IFTTT will be dispatched as events: E.IFTTT.request = data. Data passed in the request can be any - it can be a string, a number, etc. The event can execute any sequence of commands in Base. Later in this tutorial we will show how to use the location applet to trigger an event in Base.

    • E.IFTTT.request=tester A request from the IFTTT server was received with value tester.

    In the next step you need to set admin access in Base’s configurator. To do this open the Users tab and set the Admin Access option to Whole internet.

    2. IFTTT account First necessary step is registration in the IFTTT (it’s free of charge). After that you will re- ceive unique user key that will be used to call applets. After receiving the key, log in to the Base’s configurator and go to the Settings tab. Then find the IFTTT section, select the Active checkbox and paste the received key in the box below. Finally, save the Settings tab and restart the Base module. Upon restart, Base is ready to work with the IFTTT.

    3. Creating applets Creating applets is very intuitive and follows the principle "If This, Then That", exactly as the service name suggests. First step is to select an event that will trigger the applet and then action that will be executed as result of running the applet. OK, it’s time to create the first applet. The applet will be invoked when the IFTTT server receives a HTTP request sent by a DOMIQ/Base module. The request will be sent perio- dically using a timer set in Base. As an example, we will show how to send data from the outdoor temperature sensor connected to the recuperator. Data will be sent to a Google Drive spreadsheet for archiving and presentation on a graph.

    Integration with IFTTT www.domiq.eu

    © DOMIQ 2017 Page 2 z 13 TU-0024-EN-170928

  • 1. Log in to your IFTTT account and click on the My Applets, then click the New Applet. Next, click the +this to define an event that will run the applet.

    2. You’ll see long list of applets that can serve as an initiating event. We need the we- bhooks applet, so in the search box start typing webhooks. The IFTTT will begin to fil- ter matching results based on entered text.

    3. In the next step select the only available option: Receive a web request. This option assures that the applet will be triggered when the IFTTT server receives valid HTTP request.

    Integration with IFTTT www.domiq.eu

    © DOMIQ 2017 Page 3 z 13 TU-0024-EN-170928

  • 4. In the Event Name enter unique applet name. This name will be used later for calling the applet. So use as short and simple name as possible. In our case we used the temperature.

    5. Click on the +that to define an action that will be executed as a result of running of the applet.

    6. In the search box enter google and then choose the Google Drive.

    Integration with IFTTT www.domiq.eu

    © DOMIQ 2017 Page 4 z 13 TU-0024-EN-170928

  • Integration with IFTTT www.domiq.eu

    © DOMIQ 2017 Page 5 z 13 TU-0024-EN-170928

  • 7. In the next step choose the Add row to spreadsheet.

    8. In the next step define the details of adding data to a spreadsheet. In the Spread- sheet name field, enter the name of the spreadsheet. This name will be used to create a file on your Google Drive. In the Formatted row box enter the format that will be used to format data saved in the spreadsheet. Click on the Add ingredient button to see the list of available parameters: 1. OccuredAt - date and time of adding a new entry in the following format: Septem-

    ber 1, 2017 at 08:45AM

    2. EventName - The name of the event in the IFTTT service. In our example temperature.

    3. Value1, Value2, Value3 - values that can be passed as parameters of a HTTP re- quest. In our case we use only the Value1 parameter to pass temperature.

    In the Drive folder path enter the path in the Google Drive where the spreadsheet should be saved. Finally, click Create action to confirm the settings.

    Integration with IFTTT www.domiq.eu

    © DOMIQ 2017 Page 6 z 13 TU-0024-EN-170928

  • 9. In the last step, you can review the summary of the applet you are creating. If every- thing is set correctly, then create the applet by pressing the Finish button. If you want to receive a notification each time the applet is executed, set the Receive notifica- tions when this Applet runs enabled. You need to install the IFTTT app on your iOS or Android device to receive notifications.

    4. Invoking IFTTT applets in the DOMIQ In order to invoke the IFTTT applet use the following command: IFTTT=ap- plet_name?optional_data

    Let’s go back to our example of sending temperature to a Google Drive spreadsheet. As the next step we will define a timer in Base that periodically sends data to IFTTT. In our case, the timer will send data every hour. 1. Add a timer. 2. In the Minute field enter: 0 (calling every full hour). 3. In the Actions section click on the Add command... button. 4. In the Name field enter: C.IFTTT. In the Value field enter: temperature?value1={MOD-

    BUS.int.vent.outtemp} At this point we will stop for a while and discuss each part of the command. The tem- perature part is the name of the applet that the timer will invoke.The question mark se- parates the optional data part. In our case we need to pass temperature value and we will use the optional parameter to do that. The following expression does the job: ?va- lue1={MODBUS.int.vent.outtemp}. The MODBUS.int.vent.outtemp is the name of the MODBUS register that stores current value of outdoor temperature. The {identifier} syntax is new functionality in the DOMIQ, which was introduced in the system update to version 1.9.0.1. This new functionality is called dynamic bin- ding of identifiers. In software version 1.9.0.1, it was added to the Events and Ti- mers tabs and will be systematically added to the other tabs of the configurator. The

    Integration with IFTTT www.domiq.eu

    © DOMIQ 2017 Page 7 z 13 TU-0024-EN-170928

  • {identifier} expression should be understood as a dynamic reference to a identi- fier in Base to retrieve its current value. In our example we want to pass current value of outdoor temperature each time the timer is executed. Until now, it would require writing the code in the Logic tab. From now on, you can easily reference any identifier to dynamically pass its value to the timer or event you are creating. Example: Suppose the outside temperature is 18.9℃ and it’s stored in the MOD- BUS.int.vent.outtemp identifier. The ?value1={MODBUS.int.vent.outtemp} expression will be automatically converted by the B