IFTTT integration with Domoticz

From Domoticz
Revision as of 12:23, 28 January 2022 by Walter vl (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


IFTTT has a service called webhooks [1] which can be used to send and receive HTTP requests to/from Domoticz. The Webhooks Service allows you to connect IFTTT to your personal DIY projects. With Webhooks, you can connect a Recipe to any device or service that can make or receive a web request (aka webhooks).

Note: This is feature requires Domoticz stable version 4.9700 or higher.

Adding a single device to IFTT

Send a simple trigger to IFTTT using Blocky

First you need to add a Applet containing the Webhook in IFTTT.

For example create an event with the name 'Doorbell" and let it send an email.

When you are logged in at IFTTT, visit https://ifttt.com/maker_webhooks

Next press the Connect button, and after being connected, click Documentation, and copy the API/Key and paste this in Domoticz under Settings->Notifications->IFTTT (Also enable IFTTT here and Apply Settings.)

Now you can use Blockly to trigger an event. For example when the 'Doorbell' = ON send an IFTTT trigger

You will find the 'IFTTT trigger' under "Messages" in Blockly

Send a trigger to IFTTT using dzVents ( >= 2.4.18 )

If the Blocky options are to limited u can use dzVents to do the job. With this option you can use various dzVents scripts.

1. Search the key for you Webhooks service and create an applet with the name of the event (f.e. TEST_event) under the IF statement (webhooks) and select a desired THEN statement (f.e. a notification)

3. Create a custom dzVents under event in Domoticz

return {
   on = {
    devices = {'TEST'}
   },
   
    execute = function(domoticz, item)
      if item.active then
         domoticz.triggerIFTTT("TEST_event","1","testString",item.name)
      end  
   end
}

Now on change of the domoticz device TEST to "On" there will be sent "1","testString","TEST" to the event TEST_event in IFTTT

Receive a web request from IFTTT

This Action will make a web request from IFTTT to a publicly accessible URL (your Domoticz server). If not already, password protect your installation, connect to the internet and open the right ports. Because you need the username and password in the link it's adviced to create a custom user under Settings>More Settings>User settings and make a custom user. f.e. IFTTT as user with the "share"setting enabled. Get the username and password in Base64 code format with an online Base64 Encoder. This wil result in "SUZUVFQ=" for the username IFTTT


Action fields: URL, Method, Content Type, Body

This could be used in conjunction with Domoticz, when using user/password, for example as:

 THIS part : If triggered by domoticz/ Blockly or dzVents or an SMS is received (for example)
 THAT part : Add "Maker" and configure it that way :
 - URL : https://<domoticz public IP or URL>:443/json.htm?username=<user in base64 code>&password=<password in base64 code>&type=command&param=updateuservariable&idx=<idx>&vname=<variableName>&vtype=2&vvalue=<string>

or

 - URL : http://<domoticz public IP or URL>:8080/json.htm?username=<user in base64 code>&password=<password in base64 code>&type=command&param=udevice&idx=<id>&nvalue=0&svalue=string
 - Method : GET
 - Content-Type : text/plain
 - Body : Nothing

Adding multiple devices to IFTTT

A PHP script is available that makes it easier to have all of your devices on IFTTT while only requiring you to create two IFTTT applets.

You can read more about it and download here: https://github.com/dswinton/domo-ifttt