Google Home + IFTTT + Dataplicity + Local RPi + NodeRED + MQTT + Slampher + Light bulb = “Hey Google, Turn on my front light”
Ever since I bought my Google home I have been wanting to control my devices at home using voice commands. I am an IOT enthusiast I have been playing with ESP8266 wifi chip for few months now. I connected my garage to wifi and I was able to open and close my garage using my phone. There are many examples and implementations out there. Most of them use a cloud service (Free/Paid MQTT services) and an app like Blynk. Some have their local Raspberry pi exposed via Dynamic DNS service.
I am not a big fan of using a cloud service for this purpose. Most of the free services I used either did not support MQTTs or it was hard to configure or worse not reliable. I was leaning more toward the local Raspberry Pi solution as I was running MQTT service on my RPi but I didn’t want to deal with installing SSL certs or exposing my RPi via Dynamic DNS service.
The main reason I wanted my RPi to be accessible via internet is to be able to send commands via my Google home. Google home has great integration with IFTTT service. More about it later.
I recently stumbled up on a very cool service Dataplicity.io via Lifehacker and I wrote about it here. Dataplicity simplified the part I dreaded the most. SSL certificates and placing my RPi securely on the internet.
So here is how I achieved my goal of Turning ON and OFF my front light via voice command. First I had to connect my light bulb to Wifi. There are few commercial solutions out there which costs around $40 (USD). Being a fan of ESP8266 I found a cheap light holder called Slampher. I figured I could achieve the same result with just $8.50 (at the time of writing) than spend $40. There are couple of youtube videos and blog posts out there on how to hack Slampher and connect it to local network.
Once I had Slampher with custom firmware and talking MQTT on my local Wifi then I had to figure how to send commands via Google home. Google home works well with IFTTT. You can configure Google assistant applets and connect it to Maker channel in IFTTT. The missing link was IFTTT maker channel is capable of making HTTPs POST requests to an URL you provide but my devices talk MQTT not HTTP. I knew I could run a webserver on my RPi and using Dataplicity’s wormhole to create a secure end point. I needed a way to convert HTTP request to MQTT.
At first, I thought I would use Mosquitto service’s HTTP mode but I also wanted general automation and be able to configure other services as well. I had previously played with HomeAssistant. But I found HomeAssistant’s YAML based configuration counter intuitive. While searching for a reliable cloud MQTT service I had stumbled up on IBM’s NodeRED. I played with a little bit and really liked its simplicity. I was convinced it was the way to go and it could act as the missing link.
Here is how it looks today. Google Home -> IFTTT ->Dataplicity -> Local RPi -> NodeRED -> MQTT -> Slampher -> Light bulb. I was also able to automate so the light turns ON at a certain time and OFF at a certain time. I will share my code samples in my next post ! Until then Happy IOTing !
Update : Much promised code here in my next article