Google Maps Device Tracking Setup?

Hi, definitely not anything wrong from your side. I guess it is a local issue.there is an open mr on the project that might handle that. I will look into this during the weekend.

i’m on latest freshly installed hassio image.

without doing anything other than enabling the the google_maps component.
first boot: “type Error: Nonetype object is not iterable” .google… cookie file is created.
second boot" “invalid Cookies: the cookies provided do not proved a valid session…”. known_devices entry was never created.

used the mapscookiegettercli (nifty code) to generate a cookie. moved it over to /config… “cookie does not provide valid session” error again.

upgrade locationsharinglib in ha to 4.0.1 (was 3.0.x in base image) same error.

tracing the call i could see it failed out at self._session.get(self._login_url, verify=no DEBUG). it threw an exception because the page it got back contained $SIGN_IN_MESSAGE string, indicating the response page was the login prompt.

i pulled the latest locationsharinglib git and observed the same behavior via cli as well. so it seems like the problem is with the component rather than something weird hass.io is doing. i’m at a lost of what it could be tho.

hope you smarter guys can figure out what’s really going on. this is a great component. such a shame that it’s broken for so many people. :frowning:

Would you mind testing the latest locationsharinglib code locally on your workstation with the cookie you got from mapscookiegetter code and report back? It might be that your settings on the component do not refer to the cookie correctly so lets remove a few layers of complexity and make sure that the cookie is valid and that locationsharinglib can actually use it outside the context of HA. Did your cookie creation happen with no issue from mapscookiegettercli?

General steps would be to create a virtual environment, install locationsharinglib in that, and try it out interactivelly by providing the cookie file on instantiation.

I have just released a proper version of mapscookiegettercli with a fix for enforcing locale. Please pip install mapscookiegettercli and run the tool again to interactively login. If you get any issue please create an issue on https://github.com/costastf/mapscookiegettercli/issues

1 Like

hi @costas,

I’ve tried that and it worked a treat - thanks :smiley:. For others’ benefit - here’s a summary of what I did.

I was getting the ’ ‘NoneType’ object is not iterable’ error which happens when an invalid cookie file is created.

  • Using a different machine with a gui and python installed (it was a linux VM, but probably could be your main windows machine, if you install python)
  • I installed mapscookiegettercli with ‘pip3 install maps cookiegettercli’
  • Then ran maps-cookie-getter from my ~/.local/bin folder
  • That loaded up firefox browser and asked me to log in to google
  • I logged in with the user that I want home assistant to use for tracking and closed the browser
  • I copied the file location_sharing.cookies to my home assistant config folder (same folder as configuration.yaml) and renamed it to overwrite the existing cookies file.
  • config/.google_maps_location_sharing.cookies.google_user_gmail.com (the last bit depends on your google user ID)
  • I restarted home assistant - it worked!
  • I did not update locationsharinglib but am still using the same version that ships as standard with home assistant
2 Likes

By mistake i replied to this thread Platform Legacy Error - Google Maps but that is what I wanted to say :slight_smile: :+1: 1: @eggman

Thank you @costas the cookie is generating fine now with the new version(0.2.0) and only mozilla browser(chrome did not work i gave error [10136:8100:0617/171227.805:ERROR:browser_process_sub_thread.cc(221)] Waited 27 ms for network service) Unfortunately it does not fix the second problem i have that is not seeing the second tracker set up with gmaps(my wife’s phone) even though in the past it worked fine. But anyways your script is working well. Thank you again.

Not sure what you mean by second tracker. In one account (the one set up with the cookie), you have to share both accounts you want tracked. Are you doing something different?

@costas no, that is exactly how i do it. when i log in to the third account(shared one) everything looks fine but the entity in HA won’t update. To fix it in the past i just deleted the cookie file and restarted. The file was recreated and both trackers ware fine It’s been like this for a year going of and on but now with the last updates it;s broken for good.

Would you mind trying out the library by itself with debug logging on, and creating an issue on the tracker of the project if the library does not respond will all the people sharing? Disclaimer: I am leaving for vacation for three weeks, so soonest I can have a look is mid July.

I would do that if i would know how:)

You can follow documentation here https://locationsharinglib.readthedocs.io/en/latest/installation.html and here https://locationsharinglib.readthedocs.io/en/latest/usage.html. Just before following the usage also use

import logging
logging.basicConfig(level=logging.DEBUG)

I tried exactly these steps (only exception is that I did it on python 3.4 on Windows).
Used mapscookiegettercli 0.2.0 and latest firefox. It logs in and saves cookie. Renamed cookie to the same name the locationsharinglib tried to create (.google_maps_location_sharing.cookies.myusername_gmail_com) and uploaded it to the config folder on my Pi. Rebooted HomeAssistant and still got:

locationsharinglib.locationsharinglibexceptions.InvalidCookies: The cookies provided do not provide a valid session.Please authenticate normally and save a valid session again

Anyone have ideas?

mapscookiegettercli worked for me just fine. i had it running with chrome in the base Ubuntu18 VM hosting hassio itself. I tied the latest update as well unfortunately the cookie it produced was still not working with hassio.

as far as testing locationsharinglib by itself, i got the package and can setup the virtual environment for it. but i don’t know enough about how to run the module as a standalone and to pass in the cookie created by mapscookiegettercli. the usage page doesn’t say anything about standalone usage, just how to set it up the dev environment.

last week i tried a fork of your code from here: GitHub - lufton/locationsharinglib: A library to retrieve coordinates from an google account that has been shared locations of other accounts. as it provides a pre-made cli front end to accept cookie files. mapscookiegettercli cookies weren’t working it with either though. not sure which version of locationsharinglib it was forked from…

you are not alone. it does not work for me either. are you using hassio? i have a feeling everyone who got it working were using other flavors of hass instead of hassio. at least i haven’t seen any specific mentioning of it working under hass.io. i am going to try it under a fresh hass docker image see if it works better from there.

Yes, hass.io

@eggman solution does not work for me either, using hassio also.

I have hass.io and it works

pulled latest official homeassitant docker image from the hub. added google_maps into configuration with no change to anything else… did not work. same set of errors as hassio. used the mapgettercli to create a cookie… no go. same errors.

so it’s not just hass.io either.

this is baffling, especially given how it’s clearly working fine for some…

what version of hassio are you on and what hardware? did you have to do anything with the locationsharinglib such as custom_module override or upgrade it to the latest (4.0.1 i think)? did you have to use the mapscookiegettercli to create the cookie?

See inline :
what version of hassio are you on and what hardware? Raspberry PI, version 0.94.3 did you have to do anything with the locationsharinglib such as custom_module override or upgrade it to the latest (4.0.1 i think)? No did you have to use the mapscookiegettercli to create the cookie? Yes