Home Assistant is one of the best open-source home automation software platforms around. You can deploy it on a Raspberry Pi or an old laptop to build a truly private smart home. You can purchase smart devices or build your own smart switches and controllers, add them to Home Assistant, and control all of them from one dashboard.

Even better, you can also integrate Google Assistant to control all the entities and smart devices configured in your Home Assistant via your voice commands for free.

Before You Begin

To set up or integrate the Google Assistant, you must expose your Home Assistant server to the internet with an SSL certificate. To do so, you can expose your Home Assistant server with SSL using DuckDNS and Let’s Encrypt.

Alternatively, you can set up a Cloudflare Tunnel to expose your Home Assistant server to the internet. We recommend the latter method as it’s more secure and much easier to set up.

Once you can access the Home Assistant over the internet with an HTTPS connection, you can follow the instructions below to integrate and set up Google Voice Assistant in your Home Assistant server.

Create a Project in Google Console

Visit the Actions on the Google Console page and sign in using your Google account that you use with your Google Mini or Google Nest devices. Then follow these steps:

  1. Click New Project, select Yes, and click Agree and Continue.
  2. Enter a name for the project, such as "HomeAssistant" and then choose your language and country. Click Create project.
    enter the project name
  3. Choose Smart Home and click Start Building.
  4. Click Name your Smart Home action and then type a name, such as "Home Assistant". Click Save.
  5. Click the Overview tab and then click Build Your Action.
  6. Click Add Action(s) and paste your Home Assistant URL. Use one of the following formats, depending on your setup…
    • If you have used DuckDNS and Let’s Encrypt: https://[YOUR HOME ASSISTANT URL:PORT]/api/google_assistant
    • If you have used the Cloudflare Tunnel to expose Home Assistant to the Internet: https://[YOUR HOME ASSISTANT URL]/api/google_assistant
  7. Click Save and click the three dots, then select Project settings.
    open the project settings in google console
  8. Note down the Project Name and Project ID.
  9. Go to the Overview tab and click Setup Account Linking under Quick Setup.
  10. Paste and edit the following values:
    • Client ID: https://oauth-redirect.googleusercontent.com/r/[YOUR_PROJECT_ID]
    • Client Secret: type anything you want
    • Authorization URL: https://[YOUR HOME ASSISTANT URL:PORT]/auth/authorize
    • Token URL: https://[YOUR HOME ASSISTANT URL:PORT]/auth/token
    • You don’t need to enter the PORT value if you are using the Cloudflare Tunnel service
  11. Click Next > Next.
    enter the oauth client information
  12. In Configure your client (optional), type "email", then click Add scope, type "name", and click Save.
  13. Click the Test button under the Develop tab. If successful, you will see the "Test now enabled" message.
    test the service

Create a Service Account

Visit the Google Cloud Platform Console page and then follow these steps to create a service account to synchronize the Home Assistant devices with the Google Home app.

  1. Click the hamburger menu (three lines icon) on the left and choose APIs and services > Credentials.
    open api services in google cloud console
  2. Click Create Credentials and choose Service account.
  3. Type a name for the account and click Create and Continue.
    enter service account details
  4. From the Role list, choose Service Account Token Creator. Click Done.
  5. Click on the service account you just created and then click on the Keys tab.
  6. Click Add Key > Create new key.
  7. Choose JSON and click Create. A JSON file containing keys will download on your system. Rename the file as SERVICE_ACCOUNT.json.
  8. Once keys are generated, copy the key to the Notepad.
  9. Use the search bar to find and enable the HomeGraph API.
    enable homegraph api in google cloud

Edit the Home Assistant Configuration File

On your Home Assistant server, use the File Editor add-on and click on the folder icon, then the Upload icon, and click File.

Choose the SERVICE_ACCCOUNT.json file (downloaded earlier) and click OK.

upload service account json file

Next, click on the Configuration.yaml file and paste the following code.

        google_assistant:
  project_id: YOUR_PROJECT_ID
  service_account: !include SERVICE_ACCOUNT.json
  report_state: true
edit configuration yaml file in home assistant

Make sure to replace the YOUR_PROJECT_ID value in the above code with your own and click the Save icon. Then click on Developers Tools > Check Configuration to ensure the configuration is valid. If everything looks good, restart the Home Assistant server.

Set Up Home Assistant in Google Home App

Download and install the Google Home app on your Android or iOS device and then sign in to the app using the same Google account you have used to create the project in Google Console. Then follow these steps to add Home Assistant to the Google Home app and enable voice control using Google Assistant.

  1. Tap on the + icon and choose Set up device > Works with Google.
  2. Choose [test] Home Assistant (or whatever name you have given to the project). This will open your Home Assistant web page.
  3. Enter the Home Assistant login credentials and tap Login. You will see a message, "Home Assistant linked".
  4. Next, the app will show all the entities configured in your Home Assistant server.
  5. Choose all the devices in your Home Assistant that you would like to control using the Google Assistant and setup.
  6. You will see all your rooms and the devices in them in the Google Home app.

You can now control all the devices from the app and use Google Voice Assistant. You can also set up automation using the Google Home app based on various parameters. The steps are as follows:

  1. In the Google Home app, tap on Routines.
  2. Choose a trigger, such as Bedtime, and then you may type a custom voice command or keep the default values.
  3. Then, under the Actions, tap + Add action.
  4. Choose Adjust Home devices.
  5. Then choose the smart devices that are configured in Home Assistant and select further options. Tap Add action.
  6. Tap Save.

Set Up Automations With Voice Alerts

After integrating Google Assistant in your Home Assistant server to control the configured entities, such as smart lights, switches, plugs, etc. using voice commands, you can also set up automation to play voice alerts via your Google Mini or Nest Mini device.

You can use these voice assistants to announce the state or any message based on sensor values, such as when the water level sensor detects the tank is full or the motion sensor detects movement.