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

obniz – 1
battery or usb adaptor & cable – 1
Servo motor & Trash – 1
Steps
Step 1
Connect Servo motor to an obniz.
like

  1. io1: GND,
  2. io2: VCC,
  3. 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.

Program

<!-- HTML Example -->
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <script src="https://unpkg.com/obniz@2.0.2/obniz.js"></script>
</head>

<body>
<div id="obniz-debug"></div>
<br>
<div class="text-center">
  <h1> Talk with google home </h1>
</div>

<div id="text">
  <ul>
    <li>Open the trash</li>
    <li>Close the trash</li>
  </ul>
</div>

<script>

/* This will be over written on obniz.io webapp page */
var obniz = new Obniz("OBNIZ_ID_HERE");

obniz.onconnect = async function () {
  var servo = obniz.wired("ServoMotor", {gnd:0, vcc:1, signal:2});
  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>
</body>
</html>

Run Now

The html will be opened to run a program.