Inbound requests from IFTTT
The IFTTT Maker channel provides a great way to automate some common flows. One thing that has always been a challenge for me was the "that:" part of the Maker Chanel. That is, how should my "Thing" receive a Web Request, if it sits behind my router. Exposing the IP/Port from the router config makes this possible, though it is a bit of advanced.
Online PubSub Services
Online publish-subscribe services come in very handy in those cases. I've chosen for this example dweet.io for one and only reason - It is FREE and NO registration is required. That is you simply send an HTTP GET request to:
http://dweet.io/dweet/for/{ID}?{COMMAND}
Where {ID} is chosen by you, and then the recipient device polls from
http://dweet.io/get/latest/dweet/for/{ID}
It is as easy as that! I was impressed by the simplicity and usefulness of this online service
Hardware for the Example
In this example I am using an ESP8266-based device that i was developing in the past few months.
In fact now it is being crowdfunded @ indegogo - vESPrino - the IoT Dongle
Of course any device can do, just you need to connect a button and a LED. And either program it to call the URLs or use the vESPrino firmware (I am now in the process of simplifying it so stay tuned if you want it ;)
Scenario
- 1. vESPrino "Button" will trigger the Maker channel by sending an HTTP GET call to: http://maker.ifttt.com/trigger/{EVENT}/with/key/{KEY}
- 2. IFTTT will trigger the Sender Maker Channel who will send a call to dweet.io in this form: http://dweet.io/dweet/for/{ID}?cmd=led_next (led_next is a command for the vESPrino firmware to cycle the LED color)
- 3. vESPrino "LED Light" will poll dweet.io each couple of seconds and see if there are new dweets for it: http://dweet.io/get/latest/dweet/for/{ID}
Setup
If you have a vESPrino or a device with the Firmware, it takes just a couple of minutes to have a nice example running
Step 1
Create a Maker Channel in IFTTT, and configure the "this:" like this:
Step 2Create a Maker Channel for the "that:" direction and set it up like below. IFTTT will make sure to call this URL when the event is triggered. And dweet.io will store the command "cmd=led_next". (the vESPrino firmware recognizes this command and cycles the LED color)
Step 3
Setup Wifi on both vESPrinos like this:
Step 4 - vESPrino "Button"
Configure the button of the first vESPrino to send a specific event "vESPrino_bttn", to your IFTTT channel (identified by the key)
Step 5 - vESPrino "RGB Light"
Setup the dweet.io dweet id on the other vESPrino - this is where it will listen for commands
Step 6 - Action
Now connect both vESPrinos to power. Pressing the button on the first vESPrinos will cycle the LED on the second vESPrino. It takes 7-8 seconds of IFTTT to route a message between both Maker Channels (and up to several minutes for other channels). Here is how it looks like:
This is it - now you can go further and create your own DIY stuff using IFTTT and dweet.io.