Google Assistant Voice Control Anything

Inevitably, home automation is made up of many different technologies. No single company makes products that do everything you want in the way you want. Some of them go out of their way to make sure their products don’t talk to other company’s and ensure you only buy theirs. F$#ck those guys!

Anyway, here’s a simple died version of how I created a central point of control and gave it all voice control as well.  I’ve added some extra security bits and pieces to mine but I’ll leave those bits out and keep it simple here.

Accounts

Hardware

  • Google Home (or any Google Assistant enabled device)
  • Raspberry Pi

Software

  • Apache Web Server

Let’s Set it Up

  1. Install Apache on the Raspberry Pi or linux box – Basically open a terminal and run the following command:sudo apt-get update && sudo apt-get install apache2 php libapache2-mod-php -y
  2. Edit index.php and insert the following code: sudo vi /var/www/html/index.php
  3. Forward port 80 on the router to the Raspberry Pi so the internet can see your webpage

So, now if you call the web page like:

http://<your router ip>/index.php?command=sudo reboot

Your Raspberry Pi will try to run the command “sudo reboot”. Unfortunately the web page user doesn’t have permission to do that so we need to give it permission.

Run the command sudo visudo on the Raspberry Pi and add the following lines to the bottom of the document it loads:

Press ctrl+x and then press y then enter, to save and exit.

So if you install some IR repeater software or some other application you can now make it run from across the internet.

Let’s go create some voice controls.

Create the Voice Command

  1. Log into If This Then That and click to create a new Applet.
  2. Click on the “This” part to create a new trigger and select “Google Assistant”.
  3. Fill in the fields to match what you would like your voice command to be and click save.

    A sample of my voice command config
  4. Click on the “That” part to create a new action and select “Webhooks”.
  5. In the address portion, insert the IP address we made to run commands in previous steps.e.g. http://<your router IP>/index.php?command=sudo reboot
  6. Select the method as post and the body as plain text.
  7. Click save and you’re done.

    A sample of one of my hooks

So now try saying “OK Google” and then the voice command you just created.

And voila! Keep an eye on the Rasberry Pi and you should see it reboot.

 

FINAL EXTRA SUGGESTIONS

  • Change the port from Port 80 to something non standard for security
  • Include a password or check phrase for security?
  • Get some automation apps to run instead of just reboot
  • Why not use Dynamic Dns or something similar instead of the router IP address?

1 comment on “Google Assistant Voice Control AnythingAdd yours →

Leave a Reply

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