Use Google Home to Control Wireless Power Outlets

3 min read
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.