The Home Assistant Beginner’s Guide Part 3: Integrating Home Assistant with the Google Assistant/Google Home

Disclosure: This post contains affiliate links. If you click through and make a purchase, I will earn a commission, at no additional cost to you. Read my full disclosure here.

A smart speaker with a brain.
Update: Dec 31, 2022

Update: Google Home is now Nest Audio

Since my fingers first hit the keyboard for this piece, the Google Home line-up has given way to the Google Nest range. Currently, we're talking about the Nest Audio and Nest Mini. However, both are still powered by the same trusty Google Assistant found on the original Google Home devices. I've tweaked this beginner's guide to reflect these updates.

But let's be clear, this integration isn't just about turning your smart speaker into a Home Assistant sidekick. Google Assistant is sprouting up everywhere, expanding its footprint by the day. From your trusty smartphone, to wristwatches, security cams, and even car dashboards, Google Assistant is popping up like mushrooms after a rainstorm. It just so happens that Google Home was the pioneer that first introduced Google Assistant to our humble abodes.

A Google Nest Audio integrated with Home Assistant
A Google Nest Mini integrated with Home Assistant

Welcome back, home automation aficionados! As we march into the third instalment of our Home Assistant Beginner's Guide, we're delving into the task of syncing your Home Assistant with Google Assistant (which implies your Google Home, Google Nest Audio, or Google Nest Mini). By the sunset of this guide, you'll be bossing your Google Assistant around, asking it to flick the lights on in your desired hue, and handling most gizmos that you've roped into your Home Assistant.

Integration without a Nabu Casa subscription

This guide will walk you through integrating Home Assistant with Google Assistant, sans the assistance of Nabu Casa. Sure, throwing down a few bucks to use this service would streamline the process, but since I'm already lord of the domain and juggling several services alongside Home Assistant on my server, I opted for the hands-on route. That said, if you choose to shell out for Nabu Casa's monthly subscription, you'll be pitching in towards the future development of Home Assistant, which is a noble cause and one I'm not trying to dissuade you from.

Heads up, though, before you embark on this Home Assistant Beginner's Guide journey: This part might be the gnarliest yet. It involves a good dose of “coding”, and we’ll be juggling more than one tool. But fear not, I'll break it down Barney-style. We're all beginners here, after all!

Splitting hairs: Google Home, Google Nest, and Google Assistant

Before we dive head first into the actual Home Assistant Beginner's Guide, let's iron out some confusion: When I say Nest Audio, or Nest Mini, I'm talking about the hardware—the physical speaker that graces your living room. Google Assistant (GA), on the other hand, is the brains behind the operation, the software that powers the hardware. The two terms are often used interchangeably, even by Google, leading to some crossed wires. Finally, we have Google Home, which is Google's home automation service, with accompanying apps for your smartphone, smartwatch, smart speakers, and smart display.

What you need to get started

To get your Google Assistant and Home Assistant working together, you'll need a couple of things:

Getting started with gactions CLI

Your first port of call is downloading the gactions CLI⁣ – this is the command line interface that you'll use to test and update your integration.

Once you've downloaded the correct version for your operating system (most likely x86_64), copy the file into a new, empty folder. In that same folder, create a text file and rename it 'project.json' (be sure to enable 'file name extensions' in Windows Explorer, or you'll end up with a file named 'project.json.txt').

Open the file with Visual Studio Code, and populate it with the following code, replacing the URL with the one you set up with Duck DNS:

{
  "actions": [{
    "name": "actions.devices",
    "deviceControl": {},
    "fulfillment": {
      "conversationName": "automation"
    }
  }],
  "conversations": {
    "automation": {
      "name": "automation",
      "url": "https://[YOUR HOME ASSISTANT URL]/api/google_assistant"
    }
  }
}

Setting up a new project in Actions on Google

Head over to the Actions on Google developer console and start a new project. Choose a project name and your country, then hit 'create project'. You'll be greeted by a lot of jargon that might as well be in another language. Don't worry, we're only interested in the 'Actions SDK'. Click on 'Build'.

Setting up Actions on Google for Home Assistant
Such a nice welcome
Setting up Actions on Google for Home Assistant
Setting up Actions on Google for Home Assistant
Setting up Actions on Google for Home Assistant

Copy the code ('$ gactions update…') and paste it into an empty notepad – we'll need that later. In the notepad, replace 'PACKAGE_NAME' with project.json and replace the '$' with './' if you're using Windows. Here's what your code should look like on a Windows machine:

./gactions update --action_package project.json --PROJECT_NAME

Open the copied URL in a browser and fill in the required 'App information'. Once Google is satisfied with the details you've provided, click save. Next, click on 'back', select 'Account linking', and click on 'Edit'. Fill in the necessary information, and when prompted, select the implicit grant type. For the 'Client ID', you're going to need a long, random, and secure string. You could use something like the Random Password Generator for this – just make sure to select the maximum length.

Save this string in a notepad, we'll need it later. The 'Authorization URL' should be your Home Assistant URL, plus '/api/google_assistant/auth':

https://YOUR_HOME_ASSISTANT_URL.duckdns.org/api/google_assistant/auth

Giving your Home Assistant the HomeGraph API power-up

While this isn't a must-do, it's a step that's sure to make your life easier, and who doesn't want that? With the help of the HomeGraph API, your Google Assistant will be able to keep up with the latest updates on your tech terrain. Just tell it to “sync my devices”, and it'll align your Home Assistant devices with itself every time you bring a new gadget to the team or tweak an existing one. So, let's get to it. Here's how you can activate this helpful feature:

  1. First things first, head over to the Google Cloud Platform.
  2. Pick your project from the list and hit the ENABLE button.
  3. Once that's done, click MANAGE. In the menu on the left, you'll find Credentials. Click on that and then on Create credentials. From the drop-down menu, select API key.
  4. Voilà! You now have a new API key on the list. Grab it and copy it to your notepad.
beginners-guide-part-3-aog-17
beginners-guide-part-3-aog-18

Tuning up your Home Assistant

Keep your notepad at arm's reach and pull up the configuration.yaml. Here's where you'll need to conjure up another unique string for your access_token. Tweak the following code with your info, and then give your Home Assistant a quick restart from the Web UI. Be patient until it's fully booted:

google_assistant:
  project_id: ACTIONS_ON_GOOGLE_PROJECT_NAME
  client_id: CLIENT_ID_CREATED_DURING_SETUP
  access_token: RANDOM_STRING
  agent_user_id: EMAIL_ENTERED_DURING_SETUP
  api_key: HOMEGRAPH_API_KEY_CREATED_DURING_SETUP
  exposed_domains:
    - switch
    - light
    - group

Welcoming Home Assistant to the Google Home app

Now, grab your smartphone and fire up the Google Home app. Make your way to Home control (it's hiding in the menu). Tap the big + button to add new devices (in this case, our friend, the Home Assistant). The project you've just created will be sitting at the top of the list, sporting a [test] badge. Add the device and watch as all your devices set up in Home Assistant make their grand entrance!

beginners-guide-part-3-app-1
Adding Home Assistant devices to the Google Assistant
Home Assistant devices in the Google Home app
A portrait photo oif Liam Alexander Colman, the author, creator, and owner of Home Assistant Guide wearing a suit.

About Liam Alexander Colman

is an experienced Home Assistant user who has been utilizing the platform for a variety of projects over an extended period. His journey began with a Raspberry Pi, which quickly grew to three Raspberry Pis and eventually a full-fledged server. Liam's current operating system of choice is Unraid, with Home Assistant comfortably running in a Docker container.
With a deep understanding of the intricacies of Home Assistant, Liam has an impressive setup, consisting of various Zigbee devices, and seamless integrations with existing products such as his Android TV box. For those interested in learning more about Liam's experience with Home Assistant, he shares his insights on how he first started using the platform and his subsequent journey.

Comments

  1. On the Google Cloud Platform- Homegraph API- Create Credentiials I only get these options:
    OAuth Client ID
    Service Account
    Help Me Choose

    I do not see API Key.
    Am I doing something wrong?

    Reply

Leave a comment

Share to...