This custom integration aims to provide plug-and-play Google Home experience for Home Assistant enthusiasts.
Table of Contents
This is a custom component that is emerging from the community discussion of a need to be able to retrieve local Google Assistant device (like Google Home/Nest etc) authentication tokens and use those tokens making API calls to Google Home devices.
With version 1.6 we have changed the update interval from 10 seconds to 180 seconds. This is due to #202. Some people are experiencing devices timing out when trying to fetch data from them.
You can manually change the update interval by pressing the configure
button on the integration
page. Default is 180 seconds. Change this at your own risk! If your devices are timing out,
please increase this until it is stable again.
This component will set up the following sensors:
Platform | Sample sensor | Description |
---|---|---|
sensor |
sensor.living_room_alarms |
Sensor with a list of alarms from the device |
sensor |
sensor.living_room_timers |
Sensor with a list of timers from the device |
sensor |
sensor.living_room_device |
Sensor with the IP address for the device, as well as some info attributes |
You can have multiple alarms on your Google Home device. Home Assistant
alarms sensor will represent all of them in the state attributes as a list
alarms
.
Each of the alarms has the following keys:
Key | Value type | Description |
---|---|---|
alarm_id |
Google Home corresponding ID | Used to identify the alarm |
fire_time |
Seconds | Raw value coming from Google Home device until the alarm goes off |
local_time |
Time | Time when the alarm goes off, in respect to the Home Assistant's timezone |
local_time_iso |
Time in ISO 8601 standard | Useful for automations |
status |
Status (string) | The current status of the alarm, either none , set , ringing , snoozed or inactive |
label |
Name | Name of the alarm, this can be set when making the alarm |
recurrence |
List of integers | Days of the week when the alarm will go off. Please note, respecting Google set standard, the week starts from Sunday, therefore is denoted by 0. Correspondingly, Monday is 1, Saturday is 6 and so on |
The state value shows the next alarm as a time string (i.e.: 2021-03-07T15:26:17+01:00
) if there is at least one alarm set, otherwise it is set to unavailable
.
This matches state format of standard next alarm sensor provided by mobile_app
.
This sensor is formatted to be compatible with the mobile app sensor, e.g. sensor.phone_next_alarm
.
You can have multiple timers on your Google Home device. Home Assistant
timers sensor will represent all of them in the state attributes as a list timers
.
Each of the timers has the following keys:
Key | Value type | Description |
---|---|---|
timer_id |
Google Home corresponding ID | Used to identify the timer |
fire_time |
Seconds | Raw value coming from Google Home device until the timer goes off |
local_time |
Time | Time when the timer goes off, in respect to the Home Assistant's timezone |
local_time_iso |
Time in ISO 8601 standard | Useful for automations |
duration |
Seconds | Timer duration in seconds |
status |
Status (string) | The current status of the timer, either none , set , ringing or paused |
label |
Name | Name of the timer, this can be set when making the timer |
The state value shows the next timer as a timestring (i.e.: 2021-03-07T15:26:17+01:00
) if there is at least one timer set, otherwise it is set to unavailable
.
Both alarms and timers have a property called status. The status of the next alarm/timer (which is used as sensor state value) is also available through sensor state attributes next_alarm_status
and next_timer_status
respectively.
Status | Meaning |
---|---|
none |
Alarm or timer does not exist |
set |
Alarm or timer has been set |
ringing |
Alarm or timer is ringing right now |
snoozed |
Alarm was ringing and has been snoozed (only available for alarms) |
inactive |
Alarm is inactive (only available for alarms) |
missed |
Alarm was missed (only available for alarms) |
Note that timers lack the additional snoozed
state due to a limitation of the API. If you actually snooze a timer it will just reset itself to the state set
again.
This component will set up the following switches:
Platform | Sample switch | Description |
---|---|---|
switch |
switch.living_room_do_not_disturb |
Toggle Do Not Disturb mode on a Google Home device |
This component will set up the following numbers:
Platform | Sample number | Description |
---|---|---|
number |
number.living_room_alarm_volume |
Control the alarm volume on a Google Home device |
It is possible to delete an alarm or a timer with the google_home.delete_alarm
or google_home.delete_timer
services.
You can check it out in Home Assistant Developer Services Tool.
See below for the more detailed information.
service: google_home.delete_alarm
data:
entity_id: sensor.kitchen_alarms
timer_id: alarm/47dc1fa0-5ec0-2cc7-9ead-a94b85e22769
skip_refresh: true
Key | Example | Description |
---|---|---|
entity_id |
sensor.kitchen_alarms |
Entity name of a Google Home alarms sensor. |
alarm_id |
alarm/6ed06a56-8a58-c6e3-a7d4-03f92c9d8a51 |
ID of an alarm. See alarms description above. |
skip_refresh |
true |
Boolean to skip refreshing Google Home devices. |
service: google_home.delete_timer
data:
entity_id: sensor.kitchen_timers
timer_id: timer/47dc1fa0-5ec0-2cc7-9ead-a94b85e22769
skip_refresh: true
Key | Example | Description |
---|---|---|
entity_id |
sensor.kitchen_timers |
Entity name of a Google Home timers sensor. |
timer_id |
timer/6ed06a56-8a58-c6e3-a7d4-03f92c9d8a51 |
ID of a timer. See timers description above. |
skip_refresh |
true |
Boolean to skip refreshing Google Home devices. |
Note: Not all devices this integration supports can be rebooted, even if you get the message "Successfully asked xxxxx to reboot."
service: google_home.reboot_device
data:
entity_id: sensor.kitchen_device
Key | Example | Description |
---|---|---|
entity_id |
sensor.kitchen_device |
Entity name of a Google Home device sensor. |
Note: Resets the timer for automatic polling to refresh devices.
service: google_home.refresh_devices
Use Home Assistant v2024.11.0 or above.
This integration uses your google account username and app password. See 2 Factor Authentication section for tips how to setup app password. However, we strongly recommend protection your main google account by not exposing it to the Home Assistant for automation purposes. We encourage you to create a separate Google account and add it to your Google Home. Your second account would not have access to anything other than Google Home, so even if it gets compromised, it's not as severe as losing your main google account. See more discussion here
Due to authentication issues with google credentials alone it may be required to get the master token separately and provide it during the setup process. This can be done using this script or glocaltokens package.
Since there are several issues getting the token reliable on different environments, you can use a docker container which was created solely for this use: https://hub.docker.com/r/breph/ha-google-home_get-token. If you choose to use this container, run the following command:
$ docker run --rm -it breph/ha-google-home_get-token
You can find it in the default HACS repo. Just search Google Home
.
- Open the directory with your Home Assistant configuration (where you find
configuration.yaml
, usually~/.homeassistant/
). - If you do not have a
custom_components
directory there, you need to create it.
This is a preferred method of manual installation, because it allows you to keep the git
functionality,
allowing you to manually install updates just by running git pull origin master
from the created directory.
Now you can clone the repository somewhere else and symlink it to Home Assistant like so:
- Clone the repo.
git clone https://github.com/leikoilja/ha-google-home.git
- Create the symlink to
google_home
in the configuration directory. If you have non standard directory for configuration, use it instead.
ln -s ha-google-home/custom_components/google_home ~/.homeassistant/custom_components/google_home
- Download ZIP with the code.
- Unpack it.
- Copy the
custom_components/google_home/
from the unpacked archive tocustom_components
in your Home Assistant configuration directory.
- Browse to your Home Assistant instance.
- In the sidebar click on Configuration.
- From the configuration menu select: Integrations.
- In the bottom right, click on the Add Integration button.
- From the list, search and select “Google Home”.
- Follow the instruction on screen to complete the set up.
- After completing, the Google Home integration will be immediately available for use.
Make sure that you have your Home Assistant Container network set to host
, as perscribed in the official docker installation for Home Assistant.
If you are installing this integration on an ARM based device (Like Raspberry Pi, Synology, etc.), you may need to do the following if you get this error:
ERROR: Cannot install glocaltokens==0.3.1
Please run the following command in the Home Assistant container to add the missing dependencies for glocaltokens
:
apk add gcc g++
then you can install glocaltokens
manually like this:
pip3 install glocaltokens
Unfortunately, this will need to be done each time the image is updated. Alternatively you can add the command to the container startup:
command: /bin/bash -c "apk add gcc g++; pip3 install --upgrade pip; pip3 install glocaltokens; /init"
Open a PR to add your card here!
Open a PR to add your flow here!
- Alarms & timers as actionable notifications by @mattieha
- Broadcast ringing alarms & timers to other devices by @mattieha
Here are the steps to generate useful log data:
- Temporary log level change.
- Visit Home Assistant Developer Services Tool.
- Choose
Logger: Set level
from the Service menu. (the Logger service needs to be enabled for this) - Go to YAML mode and paste the following (starting on line 2):
data: custom_components.google_home: debug glocaltokens: debug
- Click Call Service.
- Read the log information.
- Visit Home Assistant Logs.
- Click Load Full Home Assistant Log.
- Look for all
google_home
andglocaltokens
entries.
- Requesting help with the log information.
- Copy the log entries.
- Paste them into a discussion forum or bug report. Make sure to use quotation block.
If you get this error:
- First verify you are using the correct Username and Password combination for that Google account.
- Have you enabled 2 Factor Authentication on that Google account? If so read the 2 Factor Authentication section to continue.
- We have seen some other custom components break the dependencies causing
google_home
to fail authentication process. For more information please see this issue. - After ruling out #1, #2 and #3 collect relevant logs and open a new issue.
The error "The setting you are looking for is not available for your account" will occur if you do not have 2 Factor Authentication (2FA) enabled on your Google account.
Here are the steps to resolve this issue:
- Open Google Account settings.
- On the top right corner click the profile photo and select the account which you would like to use.
- Go to Security page and make sure you have 2-Step Verification turned on in Signing in to Google section.
- Then visit App passwords.
- Click Select app and enter a descriptive name such as Google Home Integration for Home Assistant.
- Click the Generate button.
- Copy the password and return to the Google Home Configuration screen.
- Return to Integrations.
- Click Configure on the Google Home integration.
- Enter your Google account username.
- Paste the password into the Google account app password field.
- Click Submit.
If the debug logs list your devices, but then show Successfully initialized 0 Google Home devices
make sure you are logged into the correct Google account.
The account you are using with the integration must have access to your Home.
If unsure, please check what account you are using in the Google Home app and if your devices are listed there.
If you can see your devices, and they all seem correct, but the alarms/timers sensors do not appear, or appear empty try restarting the Google Home device, Home Assistant, and reinstalling the integration.
If you get the following error for all of your devices:
2021-11-28 16:13:20 DEBUG (MainThread) [custom_components.google_home] Failed to fetch timers/alarms information from device xxx. We could not determine its IP address, the device is either offline or is not compatible Google Home device. Will try again later.
It may be that your device and Home Assistant installation are not on the same network.
The integration works by connecting to the Google's servers to authenticate and get the authorisation keys for controlling these devices, but after that, all the requests are made locally, so it's required that the server and devices are on the same network. You can use a VPN or setup routing between each network to overcome this issue.
Your system has old version of GLIBC and therefore not compatible with pre-compiled version of grpcio.
But you can build it from sources for your system. For that in HA virtualenv run (use the version of grpcio
from glocaltokens):
pip install -U grpcio==1.46.1 --no-binary=grpcio --force-reinstall
If you encounter issues or have any suggestions consider opening issues and contributing through PR. If you are ready to contribute to this please read the Contribution guidelines.
Currently the integration supports the following languages:
- Catalan
- Danish
- Dutch
- English
- French
- German (Germany)
- Italian (Italy)
- Norwegian (bokmål and nynorsk)
- Polish
- Portuguese (Brazil)
- Portuguese (Portugal)
- Russian
- Slovak
- Spanish (Spain)
- Ukrainian
If you want to translate the project to your own language, follow the Localization guide.
- This project was generated from @oncleben31's Home Assistant Custom Component Cookiecutter template.
- Code template was mainly taken from @Ludeeus's integration_blueprint template.
- Under the hood the integration uses glocaltokens python package.