top of page

Home automation using Google assistant.

Nail Art

Introduction

Google assistant is AI (Artificial Intelligence) based voice command service. Using voice, we can interact with google assistant and it can search on the internet, schedule events, set alarms, control appliances, etc.

This service is available on smartphones and Google Home devices.

We can control smart home devices including lights, switches, fans and thermostats using our Google Assistant.(Shown below in Figure 1.1)


This application includes Google assistant along with Thinger io server and IFTTT service.

Hardware Used

  • NodeMCU – ESP8266 development board.
  • Relay module
  • Bulb

To build home automation application, I used three different platforms

  • Google Assistant
  • Thinger io
  • IFTTT

To use above services we need to configure them.


Integration with Thinger.io:

The next step is to sign up and integrate the project with Thinger.io Platform. It is really easy, just access to https://thinger.io and create a free account. Then you will have access to the platform workspace:(Shown below in Figure 1.2)


The free account allows to create 2 device connections, 4 Dashboards, 4 data buckets, and 4 Endpoints.


To create your first device just click in "Devices" menu tab and "+Add device" button. Enter details and device credentials ehich is required for code:(Shown below in Figure 1.3)



Now we will be able to control the light status from anywhere using Thinger.io web or APP console, using a switch widget or the API explorer of the device that can be accessed using the "view API" blue button of the Device Dashboard. Note that this system allows controll without delay at any conditions.


Controlling the Home appliances with Google Asisstant and IFTTT

IFTTT is a platform that allows to configure several triggers that execute some actions following a fixed structure "IF THIS THEN THAT". That trigger includes things such as, your mobile phone entered a given location, tomorrow is going to rain, you have a new mention on twitter, you have a new email, and so on. In this how-to we are going to integrate the Google Assistant APP that can be used with our SmartPhone, to create a trigger of the action (the THIS part) and a Webhooks request to send it to Thinger.io.(Shown below in Figure 1.4)


The configuration of Google Assistant is the funniest part. After giving IFTTT access authorization to our account it is possible to specify three single phrases that we want to use to trigger the acction (the three that we want) and the response from Google when the phrase has been recogniced.(Shown below in Figure 1.5)


The second part of the recipe (the THAT) will use the "Webhooks" service from IFTTT, that allows to create personalized URL for services that don't have an official channel at IFTTT. To create this URL we will need two parts, the API REST of the device and a persistent authorization, let's see this part step by step:


1)The API REST can be consulted using the device API inspector in Thinger.io, just copy the https stream.(Shown below in Figure 1.6)


2) The authorization that is shown in red text at the API REST inspector is temporal, to create a permanent one we just have to go to the device dashboard > device token and click "+add" button:(Shown below in Figure 1.7)


This button will open a popup where we can configure some parameters. Please enter a proper token name so you can recognize it in the future.(Shown below in Figure 1.8)


3) The device tokens can also expire after some time, so they provide a limited time access. We want for our device to be working forever, so the token will not expire in this case. So if we press click on create, we should see a new generated token like the one shown in the following picture. We will be using this token while configuring the IFTTT service, so keep it on hand.(Shown below in Figure 1.9)


This token will be added to the URL using an authorization identifier, at the end, in should look something like the following string. You must change the username, the device_id, the resource, and device_token according to your parameters. Removing << and >>.

https://api.thinger.io/v2/users/<<username>>/devices/<<device_id>>/<<resource>>?authorization=<<device_token>


4) Now that we have configured the url, we need to configure the information we are going to send to the device resource. We are going to submit a POST request with application/json content type that will have the same structure as the one that is showed in blue text at the API REST inspecto of our "OnOff" resource at Thinger.io platform:  

{ "in": true }


The "in" key in this JSON is used by thinger.io to indicate the resource input. It can be a boolean, a number, a string or any other value (our OnOff resource expects a boolean). This field is filled with some information available in the recipe IFTTT recipe. The recipe data can be easily put in our JSON document by placing variables with brackets {{ }}. These variables are replaced automatically by IFTTT with our new follower information. Each recipe contains different available data that you can easily check when you are composing the body.

The final configuration should look as the following picture:(Shown below in Figure 1.10)


bottom of page