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
- obniz – 1
- battery or usb adaptor & cable – 1
- 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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> <script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script> <script src="https://unpkg.com/obniz@0.1.34/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> |