Use Google Home to Control Wireless Power Outlets

Update – Just published a better method

This part 2 for my guide on how to control cheap wireless power outlets using a Google Home and a raspberry pi. Part 1 covered Siri and HomeKit. Part 3 will cover the Amazon Echo. This tutorial assumes you already setup the outlets.

Steps to Setup Google Home to control Wireless Power Outlets

  1. Create an IFTT account.
  2. Create a new service on IFTT
    1. For the if service choose Google Assistent then Say a simple phrase
    2. Fill out the options for your voice commands. For example, “Turn on the lamps”
    3. For the that service, choose Google Drive then Add row to spreadsheet
    4. Add the outlet code for the row that will be added to the spreadsheet
    5. Test your phrase to make sure it’s adding the code to the google spreadsheet. (Make sure you add the header record OutletId to your spreadsheet)
    6. You will want to follow steps 1-5 to add the on and off codes for all of your outlets
    7. Now you want to share the spreadsheet so your raspberry pi can access it
    8. You should now be able to view a json format of your spreadsheet at https://spreadsheets.google.com/feeds/list/YOUR_SPREADSHEET_ID/1/public/values?alt=json (Replace YOUR_SPREADSHEET_ID with the ID from your google sheet url)
    9. Now login to your raspberry pi and run:
      sudo nano /home/pi/googlehome.py
    10. Paste in this python script. Make sure you replace YOUR_SPREADSHEET_ID with your ID
    11. Test the everything work by running and saying your voice command:
      python /home/pi/googlehome.py

Great job if everything is working so far!

Follow the steps below to get the script to start when your pi reboots.

Start the script on reboot

  1. Run this command and paste this file
    sudo nano /etc/systemd/system/googlehome.service
  2. Create a user for the service

    sudo useradd --system googlehome
  3. Reload services

    sudo systemctl daemon-reload
  4. Enable the service

    sudo systemctl enable googlehome
  5. Start the service
    sudo systemctl start googlehome
  6. Reboot and the script should be running. If it crashes it will attempt to restart

Please leave a comment below if you have any questions or if this helped you.


Also published on Medium.

4 thoughts on “Use Google Home to Control Wireless Power Outlets

  1. Hi Tim, great guide on integration of the switches with Google Home.
    It works fine when I run it using the python script but I’m having issues with starting the googlehome.service when my Rpi 2 reboots.
    I followed your steps but when I do a “ps aux | grep -i googlehome” I don’t see the service running.
    Just wondering what might be wrong.

    Also, just wondering if you have any plans to integrate this under Samsung SmartThings.

    Thanks.

    1. Hey Bill good job so far on getting it to work! It could be that the googlehome user can’t access codesend. Try remove the user from the service. Check out this post https://timleland.com/how-to-run-a-linux-program-on-startup/. Also check out https://timleland.com/use-amazon-echo-to-control-wireless-power-outlets/. This method works for the google home. It’s a lot cleaner way of controlling the lights than using ifft. I plan on writing a new post for google home. The only gotcha that I know of is you have to use port 80 when using ha-bridge. Hopefully this helps.

Leave a Reply

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