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.
IMPORTANT
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.
Sensors
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
Alarms
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 timestring (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.
Timers
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.
Alarm/Timer status
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.
Switches
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
Numbers
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
Services
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.
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
HACS Installation
You can find it in the default HACS repo. Just search Google Home.
Manual Installation
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.
Git clone method
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:
Follow the instruction on screen to complete the set up.
After completing, the Google Home integration will be immediately available for use.
Running in Home Assistant Docker container
Make sure that you have your Home Assistant Container network set to host, as perscribed in the official docker installation for Home Assistant.
ARM Docker Container Dependencies Workaround
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:
Look for all google_home and glocaltokens 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.
"Username/Password is incorrect"
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.
2 Factor Authentication / App Passwords
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.
Paste the password into the Google account app password field.
Click Submit.
Devices found, but not initialized
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.
Devices found and initialized, but no alarms/timers sensor (#231)
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.
Device offline or not compatible message (#402)
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.
Contribution
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.
Localization
Currently the integration supports the following languages:
Catalan
Danish
Dutch
English
German (Germany)
Italian (Italy)
Norwegian (bokmål and nynorsk)
Portuguese (Portugal)
Portuguese (Brazil)
Spanish (Spain)
Russian
Ukrainian
If you want to translate the project to your own language, follow the Localization guide.
请发表评论