Google Maps
The google_maps
integration集成将 Home Assistant 与您的设备、服务等连接和集成。 [Learn more] allows you to detect presence using the unofficial API of Google Maps Location Sharing
Setup
You need two Google accounts. Account A is the account that has to be set up to share its location with account B. Account B is used to fetch the location of your device(s) and will be connected to this integration.
- You first have to setup sharing of the location of account A through the Google Maps app on your mobile phone. Share your location with account B. You can find more information here
. - Next, you have to retrieve a valid cookie from Google, while being logged in with account B. Log in with your credentials of account B on Google Maps
with a PC with Firefox or Chrome. Make sure to use the .com
TLD (e.g., maps.google.com), otherwise the cookie won’t be able to provide a valid session. After you have properly authenticated, you can retrieve the cookie with either Export cookiesfor Firefox (make sure that “Prefix HttpOnly cookies” is unchecked) or get_cookies.txt locally for Chrome/Chromium. - Save the cookie file to your Home Assistant configuration directory with the following name:
.google_maps_location_sharing.cookies.
followed by the slugified username of the NEW Google account (account B).- For example: If your email address was
location.tracker@gmail.com
, the filename would be:.google_maps_location_sharing.cookies.location_tracker_gmail_com
.
- For example: If your email address was
Note for existing location sharing users
If you already have other people sharing their location with your existing Account A and do not wish to ask them to also share their location with a new Account B. Simply repeat the steps above to obtain a valid cookie from Google for Account A. Then add both accounts to the device tracker configuration (don’t forget to include the multiple cookie files, one for each account being added to the integration).
# Example configuration.yaml entry
device_tracker:
- platform: google_maps
username: "ACCOUNT_A_EMAIL"
- platform: google_maps
username: "ACCOUNT_B_EMAIL"
If using more than one account, your own device may show twice, however, the parameters returned from Account A will not include a value for battery_level or entity_picture. These parameters will be present in your device tracker entity from Account B. Therefore, disregard the device tracker entity with is missing those parameters.
Configuration
To integrate Google Maps Location Sharing in Home Assistant, add the following section to your configuration.yaml
configuration.yaml 文件是 Home Assistant 的主要配置文件。它列出了要加载的集成及其特定配置。在某些情况下,需要直接在 configuration.yaml 文件中手动编辑配置。大多数集成可以在 UI 中配置。 [Learn more] file.
在更改了configuration.yaml
configuration.yaml 文件是 Home Assistant 的主要配置文件。它列出了要加载的集成及其特定配置。在某些情况下,需要直接在 configuration.yaml 文件中手动编辑配置。大多数集成可以在 UI 中配置。 [Learn more] 文件后,重启 Home Assistant 以应用更改。 该集成现在显示在集成页面的 设置 > 设备与服务 下。其实体在集成卡片上以及实体标签上列出。
# Example configuration.yaml entry
device_tracker:
- platform: google_maps
username: "YOUR_EMAIL"
Once enabled and you have rebooted devices discovered through this integration will be listed in the known_devices.yaml
file within your configuration directory.
They will be created with identifiers like google_maps_<numeric_id>
. To be able to properly track entities you must set the track
attribute to true
.
Configuration Variables
The email address for the Google account that has access to your shared location.
Sometimes Google Maps can report GPS locations with a very low accuracy (few kilometers). That can trigger false zoning. Using this parameter, you can filter these false GPS reports. The number has to be in meters. For example, if you put 200 only GPS reports with an accuracy under 200 will be taken into account - Defaults to 100km if not specified.
As of release 0.97 Google passwords are no longer required in your configuration. Users coming from earlier releases should only remove the password entry from their configuration file (username is still required) and restart Home Assistant. The cookie file previously generated should still be valid and will allow the tracker to continue functioning normally until the cookie is invalidated.