Google Home Integration

Google Home Integration

 

How it works

Controlling a Trash by just saying “OK Google Open the Trash!”
Google Home already has integration with IFTTT.
And IFTTT has Webhooks integration.

obniz has a messaging API.
It is easy to send message from any other webservices to obniz.
By adding Webbhooks to obniz on IFTTT, GoogleHome integrasion is as easy as possible.

Materials

  1. obniz – 1
  2. battery or usb adaptor & cable – 1
  3. Servo motor & Trash – 1

Steps

Step 1

Connect Servo motor to an obniz.
like
io1: GND,
io2: VCC,
io3: signal

Then power up your obniz.

 

Step 2

Add webhook on IFTTT.

Step 3

Write code below.
And run it on HTML or nodejs.

Code

This is a html/script for this.

<div id="online-status"></div>
<h1>Talk with google home</h1>
<div id="text">
  <ul>
    <li>Open the trash</li>
    <li>Close the trash</li>
  </ul>
  
</div>
<script>
  var obniz = new Obniz("OBNIZ ID HERE");
  obniz.onconnect = async function () {
    var servo = Parts("ServoMotor");
    servo.wired(obniz, 1, 2, 3);
    
     obniz.onmessage = function(message, from) {
        if(message === "googlehomeOpen"){
          obniz.display.clear();
          obniz.display.print("open the trash");
           servo.angle(80.0); 
        }
        if(message === "googlehomeClose"){
          obniz.display.clear();
          obniz.display.print("close the trash");
          servo.angle(0.0); 
        }
     };
  }
</script>

See the Pen Cookbook: with Google home by obniz (@obniz) on CodePen.

Leave a Comment

%d bloggers like this: