Google Maps location sharing

I’m able to hit https://www.google.com/maps/preview/locationsharing/read?authuser=0&hl=en&gl=en&pb=!1m7!8m6!1m3!1i14!2i8413!3i5385!2i6!3x4095!2m3!1e0!2sm!3i407105169!3m7!2sen!5e1105!12m4!1e68!2m2!1sset!2sRoadmap!4e1!5m4!1e4!8m2!1e0!1e1!6m9!1e12!2i2!26m1!4b1!30m1!1f1.3953487873077393!39b1!44e1!50e0!23i4111425 locally and it downloads the file just fine.

I’ve disabled the owntracks device tracker and I have ddwrt and google_maps enabled. I’m no longer getting error messages with version 1.2.2 of the locationlib but nothing gets updated in home assistant.

What you are at home your position does not show up. If you go to devices in HA do you see your tracker?

I was able to get it working by following these instructions: Google Maps location sharing … Copying that cookie file worked.

It seems for whatever reason home-assistant isn’t able to log in properly. But if I do it manually as suggested in the linked I posted above by copying the cookie file over it works.

I’m using locationsharinglib version 1.2.2

how can I install 1.2.2? Sorry Noob and can not speak English

pip install -U locationsharinglib

Might I suggest someone with rights update the doc at https://www.home-assistant.io/components/device_tracker.google_maps/ with the following?

  • 2FA and Google App passwords don’t yet work with this service and the Google account used for tracking.

  • google_maps_location_sharing.conf doesn’t seem to be used now, but .google_maps_location_sharing.cookies does get created once the service successfully authenticates to Google.

  • Once the service is working, the device will be created in the known_devices.yaml file. You can change the “name:” field, but not the first field starting with “google_maps_”. If you do, that will break the device tracking and it will be recreated as a new device again.

Otherwise, I can confirm success with Hassio 1.3, Home Assistant 0.67.1, with 2FA off and using the Google password in the device tracker’s yaml file. Looks like I might need to add single quotes around my password to get it to work in my secrets file, according to a post I read above. Will have to test…

Thanks all for your hard work on this project! Very much appreciated!
Smoke.007

1 Like

anybody can update the docs :slight_smile: click on “edit this page in github” at the top right hand corner and add any edit you want and someone will come by and leave comments etc…

I did try that first, but the only option I could see to edit, was to “fork the project and edit the file”. I don’t see an option to just suggest an edit to the file. When I do that, I get the message, “You’re editing a file in a project you don’t have write access to. We’ve created a fork of this project for you to commit your proposed changes to. Submitting a change to this file will write it to a new branch in your fork, so you can send a pull request.” Is this really what I’m supposed to do?

Yup so basically your github account will create its own fork of the documentation, and it will also create a branch for you to do edits in. From there once you make your edits you submit the PR and fill out the form and all that. Then you will see your PR show up here:

Basically you are making the changes you want to suggest and if others agree they will merge it in or provide their own feedback for what you are trying to achieve. All your notes are to help the user so I don’t see any issue with it :slight_smile:

1 Like

one easy way to do it if you have ssh access to your home assistant

  1. Create a ssh tunnel from your laptop/desktop to home assistant machine ssh -D 8080 <HASS-HOSTNAME>
  2. Use SOCKS proxy in your browser as 127.0.0.1 port 8080.
  3. Login to the google account, pass captcha stuff, etc
  4. Restart home assistant
  5. Profit
1 Like

Thank you for the explanation!

Hello again.

Just updated Hassbian to 0.68. Seems to be getting locations correctly almost all he time, but keep getting errors:

2018-04-30 01:01:11 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform google_maps
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/homeassistant/components/device_tracker/__init__.py", line 184, in async_setup_platform
    disc_info)
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/dist-packages/homeassistant/components/device_tracker/google_maps.py", line 36, in setup_scanner
    scanner = GoogleMapsScanner(hass, config, see)
  File "/usr/local/lib/python3.6/dist-packages/homeassistant/components/device_tracker/google_maps.py", line 55, in __init__
    self._update_info()
  File "/usr/local/lib/python3.6/dist-packages/homeassistant/components/device_tracker/google_maps.py", line 68, in _update_info
    dev_id = 'google_maps_{0}'.format(slugify(person.id))
  File "/usr/local/lib/python3.6/dist-packages/homeassistant/util/__init__.py", line 43, in slugify
    text = normalize('NFKD', text)
TypeError: normalize() argument 2 must be str, not None

Just as bug reporting. Thanks for your work.

I just reported the bug. If you were to report this 1 hour earlier i wont update… :cry:

https://github.com/home-assistant/home-assistant/issues/14177

I randomly started to get this error today. Not sure what changed but things were working fine on 0.68. I saw here it was suggested to update to 1.2.2 of the library but no dice.

This is the error I get:


Error setting up platform google_maps
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/device_tracker/__init__.py", line 184, in async_setup_platform
    disc_info)
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/device_tracker/google_maps.py", line 36, in setup_scanner
    scanner = GoogleMapsScanner(hass, config, see)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/device_tracker/google_maps.py", line 55, in __init__
    self._update_info()
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/device_tracker/google_maps.py", line 67, in _update_info
    for person in self.service.get_all_people():
  File "/srv/homeassistant/lib/python3.6/site-packages/locationsharinglib/locationsharinglib.py", line 324, in get_all_people
    people = self.get_shared_people() + [self.get_authenticated_person()]
  File "/srv/homeassistant/lib/python3.6/site-packages/locationsharinglib/locationsharinglib.py", line 291, in get_shared_people
    output = self._get_data()
  File "/srv/homeassistant/lib/python3.6/site-packages/cachetools/__init__.py", line 46, in wrapper
    v = func(*args, **kwargs)
  File "/srv/homeassistant/lib/python3.6/site-packages/locationsharinglib/locationsharinglib.py", line 285, in _get_data
    return json.loads(response.text.split("'", 1)[1])
  File "/usr/lib/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.6/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)```

EDIT: For anyone else getting this error, delete the cookies file and restart home assistant seems to have done the trick for me.

Ok that issue came back again within 10 minutes and now it doesn’t seem to go away no matter what I do. Not sure what happened here.

EDIT: just restarted home assistant and its working again, something odd is happening maybe its at google’s end???

I asked the question in this posthttps://community.home-assistant.io/t/new-google-maps-device-tracker-issue/50328/8?u=penright because someone else had the same issue. Reading this post, maybe here is a better place.
After going through all the setups, I am at the point where you get “The cookies provided do not provide a valid session.Please authenticate normally and save a valid session again” error.
I saw where many talked about deleting cookies, unless I missed it, there was no mention of where they are at.
What should be the next step?

Here is my log for reference.

Thu May 03 2018 13:52:11 GMT-0500 (Central Daylight Time)

Error setting up platform google_maps
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/components/device_tracker/__init__.py", line 184, in async_setup_platform
    disc_info)
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/device_tracker/google_maps.py", line 36, in setup_scanner
    scanner = GoogleMapsScanner(hass, config, see)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/device_tracker/google_maps.py", line 54, in __init__
    hass.config.path(CREDENTIALS_FILE))
  File "/usr/lib/python3.6/site-packages/locationsharinglib/locationsharinglib.py", line 184, in __init__
    if cookies_file and self._validate_cookie(cookies_file):
  File "/usr/lib/python3.6/site-packages/locationsharinglib/locationsharinglib.py", line 211, in _validate_cookie
    raise InvalidCookies(message)
locationsharinglib.locationsharinglibexceptions.InvalidCookies: The cookies provided do not provide a valid session.Please authenticate normally and save a valid session again```

issue came back again, this component seems to be really iffy with how frequently it breaks and fixes itself

@michaelarnauts I notice you contribute to both google_maps.py and locationssharinglib. Can you help with a couple of questions?

I notice on github under the dev branch, it is “REQUIREMENTS = [‘locationsharinglib==1.2.2’]”
Looking at the code currently installed, it is “REQUIREMENTS = [‘locationsharinglib==1.2.1’]”
Looking at the website http://locationsharinglib.readthedocs.io/en/latest/contributing.html 1.2 was released 4/2/2018.
Does that have the credential/cookie fix?

Looking at the google_maps.py code, I am guessing the magic happens in the location sharing lib (LSL).
I am a .NET not a python programer, but REQUIREMENTS looks like a variable/constant. I don’t see where it is used, so I assume it is used as a remark. Just for grins, I did try and change it to 1.2.2 and it did not make a difference.
I am running hass.io and I do have developers ssh (-p 22222) enabled.
Can I and how do I install the latest LSL?

Restarted home assistant again this morning and it started working again :confused:

This is different. I wanted to show the error when loging in whitout cookies. ie: first time.
I deleted the cookie and restarted hass. This is my error …

Log Details (ERROR)
Fri May 04 2018 09:52:45 GMT-0500 (Central Daylight Time)

Could not open pickle file, either file does not exist or no read access.

Expecting it not to be there, did a “ls -la” and it was there.
So I just deleted it and trying again. Same thing.

Something maybe getting cache so this time I waited till the “lost connecting”… Same thing.

I am changing my “REQUIREMENTS = [‘locationsharinglib==1.2.2’]” back to 1.2.1 and see what happens.
Same thing.

So this time I am restarting hass, with my google_maps rem out. Then I will delete cookie and see what happens. … Same thing.

I wonder if there is a race condition. Been looking at the LSL code and still trying to get the lay of the land. As I said, I am more .NET, but as all languages there are similarities and nuances. I wonder if some of the sessions calls are non blocking. As I said, I not sure about python.
For now I guess, i am giving up, unless someone has an idea.