This is an easy way to get commands from Google Assistant to an ESP8266-based device under NodeMCU firmware (Lua).
The project uses the IFTTT platform where Google Assistant and Webhooks Service can be assigned to work together. Using this functionality we can set our device to wait for specific commands to arrive and then get decisions according to the voice command.
So we can say "Hey Google, device on" and use this voice command to turn on an output on our project or say "Hello Google, my device off" and turn it off. To achieve this, an applet should be created on IFTTT.
From ESP8266 programming side we need to setup a specific web server and set it wait for commands and then decide what to do with each command.
An connection to internet is required (obviously) for the ESP8266. Additionally we have to set up a dynamic DNS (this step can be omitted if the connection has a static IP address) and we have to forward the web server port, which is set 8077 for our example. More info on port forwarding can be found on https://portforward.com/
IFTTTWe should create an applet on IFTTT service using its web interface.
This can be done by following the steps:
- Login to the account (or create one and login) and navigate to my applets
- Select New Applet
- Select "+this"
- Search for "Assistant" and select the only result available
- Select "Say a phrase with a text ingredient"
- Complete the fields and hit "Create trigger"
- Select "+that"
- Search for "Webhooks" and select the only result available
- Select "Make a web request"
- Complete the fields and hit "Create action"
- In the final screen rename the applet and select if notification for each time the Applet runs.
- Click Finish to save the Applet
A detailed guide for IFTTT can be downloaded using the following link: https://github.com/limbo666/IFTTT_to_ESP8266/blob/master/Assistant_guide/Assistant-IFTTT.pdf
ESP8266ESP8266 must be flashed with NodeMCU firmware.
The Lua file can be found on https://github.com/limbo666/IFTTT_to_ESP8266
The provided file is a server which can be turn on one GPIO. The keywords "on" "enable," "turn on," "off," "disable" turn off" and "test" are predefined on the code. Altering the Lua file and adding more keyword is pretty easy.
TestingTo test the script locally, on your LAN you can use any browser and type http://xxx.xxx.xxx.xxx:8077/Webhooks:on (replace xxx.xxx.xxx.xxx with the actual IP address of ESP8266 module).
With the same server, you can get commands from any other IFTTT enabled service like, weather underground, twitter, facebook, gmail, dropbox, Android phones and many other services. A complete list of supported services can be found here. You should create an applet for each service you like selecting as action webhooks and filling the details on the action fields.
Additional UsageSince we are running a standard web server we can send commands to the device directly to it in other ways.
You can use vb scripts to send commands to the server from your Windows desktop or use an Android app to create rules o control it directly.
Macrodroid is a great app that can send commands based on a variety o triggers.
RemarksThis project is only for getting info from IFTTT (and Google Assistant). If you want to send triggers to IFTTT you refer to the following links:
https://www.hackster.io/noelportugal/ifttt-smart-button-e11841
https://www.hackster.io/noelportugal/esp8266-ifttt-easy-button-888a87
Comments