integration with the ifttt - domiqdomiq.de/data/tu/tu-0024-en-170929.pdf1. log in to your ifttt...

13
Integration with the IFTTT The IFTTT (ang. If This Then That) oers 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 aect 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

Upload: others

Post on 28-May-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Integration with the IFTTTThe IFTTT (ang. If This Then That) offers plenty of useful applets, that allows to automatedaily 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 andthus run created applets. There is also reversed functionality - the applet can send aHTTP request to the Base module and in result invoke any event. How does this affectBase functonality? Let's just list a few of the most interesting features and new arrivalsare 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 triggercreated 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 inthis tutorial.

1. Integration with the IFTTT in the DOMIQAs 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 serverFor 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 tothe IFTTT server.

Integration with IFTTT www.domiq.eu

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

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

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

1.2. Receiving HTTP requests from the IFTTTTo receive HTTP requests from the IFTTT server, public IP address is required. If you onlyhave a dynamic public IP address, then use dynamic DNS. You’ll also need to redirectport in router settings to point local IP address of your Base module and port number thatmatches value of the Web Port parameter (default is 80) set in Base’s configuration (theSettings 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. Theevent can execute any sequence of commands in Base. Later in this tutorial we will showhow to use the location applet to trigger an event in Base.

• E.IFTTT.request=testerA 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 theUsers tab and set the Admin Access option to Whole internet.

2. IFTTT accountFirst 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. Thenfind the IFTTT section, select the Active checkbox and paste the received key in the boxbelow. Finally, save the Settings tab and restart the Base module. Upon restart, Base isready to work with the IFTTT.

3. Creating appletsCreating applets is very intuitive and follows the principle "If This, Then That", exactly asthe service name suggests. First step is to select an event that will trigger the applet andthen 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 serverreceives 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 theoutdoor temperature sensor connected to the recuperator. Data will be sent to a GoogleDrive 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 optionassures that the applet will be triggered when the IFTTT server receives valid HTTPrequest.

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 callingthe applet. So use as short and simple name as possible. In our case we used thetemperature.

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

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 createa file on your Google Drive. In the Formatted row box enter the format that will beused to format data saved in the spreadsheet. Click on the Add ingredient button tosee 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 exampletemperature.

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 spreadsheetshould 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 wantto 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 iOSor Android device to receive notifications.

4. Invoking IFTTT applets in the DOMIQIn 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. Asthe next step we will define a timer in Base that periodically sends data to IFTTT. In ourcase, 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 Base at the time the timer is called to: temperature?value1=18.9.

5. Save the Timers tab to apply changes.

5. Handling IFTTT applets in DOMIQAs mentioned in the chapter 1, the Base module can receive requests sent from theIFTTT server. It’s dispatched as event in the following format: E.IFTTT.request=data.As an example of this functionality, we will present the Location applet, that can be calledwhen user enters or leaves given location. In our example, we will use this applet to initia-lize an event for residents returning home.

5.1. Applet configuration1. 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.

Integration with IFTTT www.domiq.eu

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

2. In the search box type: location.

3. In the next step, choose the You enter an area, as the event is to be triggered whenuser enters the location.

Integration with IFTTT www.domiq.eu

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

4. Specify the location.

From our experience, we recommend to install the IFTTT app for mobile devices to fine-tune the location once the applet is created. The mobile app allows you to pinpoint a lo-cation based on the current location of your mobile device. This way you can, for exam-ple, you can define the applet to run when you enter the property.5. Click on the +that to define an action that will be executed as a result of running of the

applet.

Integration with IFTTT www.domiq.eu

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

6. In the search box enter webhooks.

7. Choose the only available option - Make a web request, which means that each timethe applet is called, it will send a HTTP request to a given address.

8. In the next step define the address to which the request will be sent. In our example,we entered: http://example.com/call/ifttt/home. The example.com has to be replacedwith the public IP address of the Base or dynamic DNS address. The /call/ifttt/ part ismandatory and must be included in every request sent from the IFTTT to the Basemodule. The last part of the address, in our case home, is the data that will be passedto the Base module. The data will be passed within the E.IFTTT.request event (seedescription of event definition in next subsection). Leave the GET value in the Methodfield. The rest of the options can be omitted.

Integration with IFTTT www.domiq.eu

© DOMIQ 2017 Page 11 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 wantto 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 iOSor Android device to receive notifications.

5.2. Event configurationFinally we can define event for returning home. 1. Navigate to the Events tab and add an event. 2. In the Channel field enter: E.IFTTT.request. 3. In the Data field enter the name that used in applet definition. In our example: home. 4. To avoid multiple (unwanted) event calls (eg when another resident returns home), a

condition must be added to prevent this. If a Satel control panel is present in your in-stallation, you can use the state of the an alarm zone to determine the presence of re-sidents. However, if you do not have a Satel control panel in your installation, then youcan choose one of the alternatives:1. Set a MEM variable or a virtual LCN relay based on motion sensor (

no motion detected for a specified time would be interpreted as the absence of re-sidents at home). In this case, any number of sensors can be used to set a MEM ora virtual relay.

2. Define a wall button, which when pressed when leaving the house will set a virtualLCN relay or a MEM variable.

In our example we assume that the Satel alarm panel is present and zone no. 1 is theone that is armed when residents leave home. So in the Condition field, type: IDS.ar-med.1 == 1.

5. Finally, in the Actions section, define the sequence of actions you want to perform asa procedure for returning home.

Integration with IFTTT www.domiq.eu

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

In this tutorial we have just presented two examples of many possible applicaitons of inte-gration with the IFTTT. We hope that with this functionality, your smart home will be evenmore tailored to your needs.

Integration with IFTTT www.domiq.eu

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