Google Maps Location Sharing not working in Hass.io

Hi all, I just installed Hass.io on my Rpi3. Clean install of Home Assistant
0.84.6.

I when added google location component to configuration.yaml file as described here:

device_tracker:
  - platform: google_maps
username: [email protected]
password: secret

But when I restart the system I get these 2 errors:

Unable to load /config/known_devices.yaml: Config file not found: /config/known_devices.yaml

Error setting up platform google_maps
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/__init__.py", line 183, in async_setup_platform
    disc_info)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/google_maps.py", line 46, in setup_scanner
    scanner = GoogleMapsScanner(hass, config, see)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/google_maps.py", line 66, in __init__
    self._update_info()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/google_maps.py", line 78, in _update_info
    for person in self.service.get_all_people():
  File "/usr/local/lib/python3.6/site-packages/locationsharinglib/locationsharinglib.py", line 465, in get_all_people
    people = self.get_shared_people() + [self.get_authenticated_person()]
  File "/usr/local/lib/python3.6/site-packages/locationsharinglib/locationsharinglib.py", line 426, in get_shared_people
    for info in output[0]:
TypeError: 'NoneType' object is not iterable

Temporary work-around here:

https://github.com/home-assistant/home-assistant/issues/17410#issuecomment-440357856

I got it working!

It wasn’t easy at all!

The process is briefly described in the topic linked above. But I nearly killed myself before I figured it out! So for all noobs like me here is the “easy” explanation of what to do:

  1. First of all add the “device_tracker” component to HA configuration.yaml file. Restart HA and check if you get any errors in the log. I got 2 errors: missing “known_devices.yaml” file and “Error setting up platform google_maps”. As I wrote above. To fix the “known_devices.yaml” file issue just create the file manually - step #8.

  2. You will need a working linux operating system. I used Linux Mint running in Oracle VW Virtual machine.

  3. Log in to your linux system. You will when need to install something called " virtualenv" and something called “virtualenvwrapper”. For that I followed this guide:
    https://gist.github.com/hangtwenty/5671021#file-linux_mint_python_development_environment_setup-sh
    Open the terminal window program in linux.
    I just copy/pasted all the commands from that page into my linux terminal window.

  4. As soon as I installed the above mentioned “virtualenvwrapper” I checked that it works by typing “mkvirtualenv foo” in to the terminal window, as suggested by the guide above. And surprisingly it worked!

  5. You will also need to install “git”. Copy and execute following command in terminal window: sudo apt install git

  6. Now you are ready to follow the instructions on creating a new cookie file for google location sharing service.

  7. Copy/paste following command one by one in to the linux terminal and execute:

git clone https://github.com/lufton/locationsharinglib.git
cd locationsharinglib/
mkvirtualenv -p `which python3` locationsharinglib
pip install -r requirements.txt 
python cli.py --email '<your email>' --password '<your password>' --cookies-file .google_maps_location_sharing.cookies

But make sure to change <your email> and <your password> with your email and password for google location sharing service respectively. Also before executing the last line in the terminal make sure it is properly copied when you paste it. I had a problem where it wouldn’t paste properly. So I pasted it inside notepad first, changed my email and password and then copied it to terminal window.

  1. After you executed the last command, if there was no errors, you should have the cookie file ready. Open the folder browser. Go to home folder. Find a folder called “locationsharinglib” and go inside. Make sure to switch on “show hidden files”. Find the file called “.google_maps_location_sharing.cookies”. Copy that file into home assistant config folder. I used samba share to do it. It will tell you that where is already such a file in the folder. Just overwrite it.

  2. You will also need to manually create “known_devices.yaml” file in HA config folder.

  3. Now go back to HA configuration web page and restart HA. If all goes well after restart you will see your location icons in the overview page top next to the sun and weather icons.

1 Like

Does it keep working though? I find that I have to recreate the cookie every couple of weeks.
Anybody working on a more permanent solution?

I’m running Hass.IO from Ubuntu 16.04, hosted on a Hyper-V VM. With mine, I found that there was a DNS issue (accidentally, through cross-referencing an issue another user was having with Life360). I fixed it by creating /etc/docker/daemon.json and adding the following: {“dns”: [“8.8.8.8”, “8.8.4.4”]}

This also fixed an issue I was having with Google Text to Voice.

I really hope this keeps working for you because I liked having Google Maps Location Sharing. However, its never been reliable for me. If you do find that this stops working, I would definitely recommend giving life360 a go: -

Hi @AJStubbsy & @marmar63!

You might be interested in this (if you haven’t seen it yet):

I explain how I use both Google Maps Location Sharing and Life360. Although this particular post is about how Life360 tends to be more up-to-date, I’ve actually found that using them both provides a better overall solution.

1 Like

@Pnbruckner this looks like good information, I"ll have to dig into this later and see what it looks like :slight_smile: