Tuesday 2 October 2018

Controlling Tuya (Smart Life) Devices from IFTTT


I have a number of Tuya (Smart Life) lightbulbs and while these are integrated seamlessly with Amazon Voice Services and Google Home, I would also like to be able to control remotely, via Python and also directly by voice from my XMOS VocalFusion™ Stereo Dev Kit (https://www.xmos.com/support/boards?product=37033).
I looked into the Tuya API (https://iot.tuya.com) and decided that it would be much easier to control the lights via IFTTT.

Here is a step-by-step guide.

First we need to enable Webhooks, to allow us to trigger the event via a URL. To do so, search for “Webhook” here : https://ifttt.com/search

Click on "Webhooks" and activate it.


This will give you a URL that looks like : https://maker.ifttt.com/use/xxxxxxxxxxxxxxxxxx
Where xxxxxxxxxxxxxxxxxx is your key, which we will use later.

To create a private Applets go to : https://platform.ifttt.com/p/username/applets/private - note the username is your IFTTT username.



Click New Applet and fill out the fields :




Note for triggering events using URLs I find it easier to ensure there are no spaces in the trigger name e.g. “Turn_On_Light”.
Scroll Down to Action and enter the details :




Enter a Title and Description. I just used “Turn On Light”

Click Save.
Click “Enable On IFTTT”
Turn The Applet On.


You can also create an Applet to turn off the Light. Or to make it easy, just go to the Applet Preview Page and hit “Copy” for the above Applet.
Modify the details of the new Applet and click Save.

You can view your private Applets here : https://platform.ifttt.com/p/username/applets/private

To test your Applet go to here : https://maker.ifttt.com/use/xxxxxxxxxxxxxxxxxx

Enter then name of your Applet “Turn_On_Light” in {event} and click “Test It”.

Now our Applets are setup and tested we only need the URLs for turning on and off the light, these are :

https://maker.ifttt.com/trigger/Turn_On_Light/with/key/xxxxxxxxxxxxxxxxxx

https://maker.ifttt.com/trigger/Turn_Off_Light/with/key/xxxxxxxxxxxxxxxxxx

To trigger the events, just open up the above URLs in a browser and you should be able to remotely control the light.

Alternatively, using Python requests you can do :

import requests
requests.post("https://maker.ifttt.com/trigger/Turn_On_Light/with/key/xxxxxxxxxxxxxxxxxx")

If you have found this solution useful then please do hit the Google (+1) button so that others may be able to find it as well.

Numerix-DSP Libraries : http://www.numerix-dsp.com/eval/

5 comments:

  1. if i wanted to do a webhook to change my tv buy numbers and not scenes how can i do that with variables such as say on google or alexa press : 123

    ReplyDelete
  2. Hi Damian,
    I'm sorry, I don't know but if I find a solution I will post.
    Best,
    John

    ReplyDelete
  3. It said "there was a problem creating this applet" when I tried to turn it on how do I fix this.

    ReplyDelete
    Replies
    1. Sorry, I don't use IFTTT anymore so I have not seen this

      Delete