Google Home and IFTTT, turn on the stove

In this post we can view a method for turn on the stove. It’s very¬†comfortable and futuristic send command by voice to the stove… ūüėČ For make this things you have to knok the IFTTT service. Do you know? The website is www.ifttt.com.¬†

ifttt
ifttt

 

How works IFTTT?

IFTTT works in this way. First of all, login and subscribe with your Google Account. In this way your Google Home is automaticaly recognized. Now you have to create your first Applet. One Applet is composed by 2 parts…. the input or “This” part, and the output or the “That” part. In “This” part (the input) you have to select the service Google Assistant. Now I selected “Say a simple phrase” and i write “Turn on the stove” (realy I’m italian and I write “Accendi la stufa”).

In the second part, the “That” part, I select the service WebHook… that is a method for call a URL…. Most probabily you have just understand that we call a URL in our raspberry… we call an API like we saw in this post¬†https://www.gioexperience.com/1-05-a-quick-webapp-for-your-thermostat/

I have a static IP in my home… but if you don’t have a static IP you can resolve using a DinamycDNS… I suggest¬†https://www.duckdns.org/

duckdns
duckdns

In my case, the url is http://xxx.xxx.xxx.xxx/api/ifttt/?key1=stufa&key2=accendi&token=xxxxxxxxxxxxxxxxx

Obviously I inserted xxxxxxx for my privacy.

Now, when I say “Turn on the stove” to my Google Home, IFTTT website calls the URL, and the script turn on the stove!

Now, you can write another Applet for TURN OFF the stove.

Use your script controlled stove

Obviously this post is based on the other post in this website where we make a stove controlled with a raspberry ūüôā
Look at this posts

1.01
1.02
1.03
1.04
1.05

The API in Raspberry

In my raspberry I created a file ifttt.php dedicated for receive commands from IFTTT. In this way I can control all voice commands.
This script is almost this

<?php include(*****/init.php");

if( $_GET["key1"]=="stufa" )
{
   $json=json_decode(file_get_contents("http://127.0.0.1/api/temperature/"),true);

   if( $_GET["key2"]=="accendi" )
   {
      if( $json["statoStufa"]==1 ) die();
      //imposta le soglie come piu alte della temperatura attuale.
      $t0=ceil($json["t0"])+0.5;
      $t1=ceil($json["t1"])+0.5;
   }

   if( $_GET["key2"]=="spegni" )
   {
      if( $json["statoStufa"]==0 ) die();
      //imposta le soglie come piu basse della temperatura attuale.
      $t0=floor($json["t0"])-1;
      $t1=floor($json["t1"])-1;
   }

   file_get_contents("http://127.0.0.1/api/temperature/?op=set&soglia0=$t0&soglia1=$t1");

}

You can see that in the first case, “accendi” or “turn on”, the script write a thresold temperature higher than current temperature. In the second case, “spegni” or “turn off”, the script write a threshold temperature lower that current temperature.

I use this script and this way almost from 6 months and it’s comfortable and very usefull. : )

Please follow and like us:

Leave a Reply

Your email address will not be published. Required fields are marked *

Fork me on GitHub