Home Assistant and Google Actions



Originally posted 2017-10-31 13:40:06.

google home mini

So I just got another Google Home – but this one is a Google Home Mini. I got this one for my office so I can listen to background music easily without blasting music everywhere at home.

I’m also planning on getting a mini for our bedroom to listen to music with the new sleep timer that was recently introduced.

However, the purpose of this post is to speak about the Google Actions Integration with Home Assistant. You will remember from my previous blog posts about controlling my Limitless LED lights with Google Home that I used the integration with IFTTT to control the lights. However, the people at Home Assistant have just released a new integration with Google Assistant and I wanted to give that a try even though I already have good control with IFTTT.

I asked about this on the Home Assistant support forum and got a reply:

‘A couple benefits of “native” integration with HomeAssistant, Google Assistant will know the state of your devices and you can group them into rooms within the Google Assistant app. The response time seems to be about the same as IFTTT – maybe ever so slightly faster.’

In reality, having now done the integration, I have no more control than I did before and a few annoyances that I’ll explain.

Edited to add…

Just further to that, one benefit of this integration over using IFTTT is the ‘fuzzy logic’ IFTTT is rigid – you give it 3 ways to say something and if you don’t follow that exactly then IFTTT does not understand and won’t trigger the action. If you use the integration it’s a little smarter. WIN!

Setting it all up.

The instructions supplied are very good and I won’t repeat them here. Just a couple of notes/traps.

  1. On your raspberry pi, if you run the command:
    cat /dev/urandom|fold -w 120|head -n 1|base64 -w 0|tr -dc ‘0-9A-Za-z’|cut -c -80
    An 80 character string is output that you can copy and paste and use as the client_id. Repeat the command a second time to generate an access_token. Think of these like a username and password. As your Home Assistant is exposed to the Internet you want this to be a long, random, complex string such as the one the  linux command above will generate for you and will be pretty hard for some hacker to crack.
  2. When you enter the client_id and the access_token into your configuration, do not include the [] at the start and end of the string
  3. After you edit the configuration.yaml you need to re-start home assistant by either rebooting the raspberry pi or from the command line.
  4. The ‘customize’ section is optional and you can leave it out for now.
  5. The instructions tell you to install the gactions.cli without actually telling you how. On my Pi, I downloaded the file from the link and put it in a folder called gactions on my Pi. When I ran the command to make it executable, I had to include ‘sudo’.
    sudo chmod +x gactions
  6. Similarly, when I executed gactions, I needed to add ‘sudo’ otherwise when I got the authorisation code from Google it would not install and gave an error. Use this command:
    sudo gactions update –action_package PACKAGE_NAME –project doctest-2d0b8
  7. When configuring your project you will need a JPG file for the project and for the icon. Just pick any suitable file of at least the requested resolution. Google will crop it if it’s too big.
  8. When it tells you to open the Google Assistant App, it’s not immediately obvious (at least to me) but it means the App on your phone, iOS or Android.

From that point it was pretty clear sailing except for one thing. I have a Belkin Wemo switch already in my home assistant and Google Home has native support for this device already. This meant as I followed the instructions to the letter, I had additionally exposed the switch domain to the google assistant integration. This meant I had the switch ‘double configured’ and could not control it because Google Home did not know which switch or which coffee maker I was talking about. I did fix this by renaming the nickname in Google Assistant to another name, however if I continue to use the old name it plays dumb and says it does not know which coffee maker I am talking about. I will most probably remove the switch from the exposed domain list however if I get another switch at some point…….. I could also unlink the wemo from Google as that would give me one unique coffee maker.

It’s been a fun learning exercise anyway.






Edit to add…

I did remove the specific switch from the Google Integration and it’s worth spelling out how I did it. I also added some scenes for further light control. It is possible to add the ‘scene’ domain to be exposed by Home Assistant.

First things first.

To remove the specific switch, I used the customize.yaml file shown below. Customize.yaml was automatically created (with 0 bytes) when I setup Home Assistant and the include command was already added to configuration.yaml (see earlier posts for information on this)

customize.yaml:

switch.coffeemaker:
  google_assistant: false

Next thing was to add the scene domain to configuration.yaml:

# Google Assistant
google_assistant:
  project_id: !secret ga_project
  client_id: !secret ga_client
  access_token: !secret ga_access
  exposed_domains:
    - switch
    - light
    - group
    - scene

The only other thing is to show the scenes I added. These are in a file called scene.yaml:

#Lounge Light Scenes 
 - name: Lounge 100
   entities:
     light.lounge:
       state: on
       transition: 2
       effect: white
       brightness_pct: 100
 - name: Lounge Normal
   entities:
     light.lounge:
       state: on
       transition: 2
       effect: white
       brightness_pct: 75
#      color_temp: 500
 - name: Lounge Movie
   entities:
     light.lounge:
       state: on
       transition: 2
       brightness_pct: 30
       rgb_color: [0,0,255]
# Office Light Scenes 
 - name: Spots Normal
   entities:
     light.spots:
       state: on
       transition: 2
       brightness_pct: 75
       effect: white
#      kelvin: 3100

Note the color_temp and kelvin settings are commented out as I am having a lot of trouble with the Lounge Room lights for some inexplicable reason being locked to ‘blue’ when they are switched on by Home Assistant and those settings are invalid when the light is in RGB rather than white mode. If I activate the exact same scene a second time they change to white mode again. I can’t tell you how damn annoying this is and I just can’t seem to solve it (yet!) This all started when I started playing with the movie mode. (Removing the temperature setting seems to have fixed this)

If/When you add these to Home Assistant, you have to unlink the (You go into the Google Assistant App>Settings>Home Control, click on … in top right corner > Manage Accounts, tap on the linked ‘app’ in my case it’s called [test] Home DEW and you can then unlink it. Then re-link it from the Add new list. I’m sure this is fluent gibberish but when you use the app it’s reasonable clear if you have these pointers.

When you re-link the app, you will need to configure the rooms again etc. Also remember when you have added the scene.yaml, edited customize.yaml and configuration.yaml that you need to either reboot the Pi or restart Home Assistant before you can re-link the app and use the new settings.

Have fun!

Leave a comment or ask any questions below.



Leave a Reply