Google Maps Device Tracking Setup?

Hello

Do i need ti install addon first or only adding to configration.yaml

1 Like

It seems that I missed this thread, so posting here too.
Hi all, I have created an alpha of a cookiegetter project that drives a browser through selenium and saves the cookies. Please look at https://github.com/costastf/mapscookiegettercli/blob/master/USAGE.rst for usage (it is quite simple :slight_smile: ) and report issues at the tracker.

2 Likes

Thanks, I was able to get location tracking working again using this method!

Thank you very much! I tried so many thing and already gave up. Today I just looked through my bookmarks and decided to look inside. And it worked! Amazing.

How Can this be followed using hassio

This is something that you would install on your workstation with a gui. It will pop up a browser, you log in Google and it will create a valid cookie file for you. You copy that cookie file over to your hassio installation with any method you like and configure the add-on to use that cookie file.

1 Like

Hi @costas, i did install python 3.7 32 bits on my station . Runned the installer and executed the command put in my credentialls but the browser won t close and just sits there.

2019-06-14 17:33:18 Mihai-PC chrome.bootstrapper[12948] INFO Deleting all cookies
2019-06-14 17:33:18 Mihai-PC chrome.bootstrapper[12948] INFO Returning driver
2019-06-14 17:33:18 Mihai-PC cookiegetter.CookieGetter[12948] INFO Starting interactive login process.

is there anything i am doing wrong ?

and if i close the browser manually i get :slight_smile:
[4360:13980:0614/180456.743:ERROR:browser_process_sub_thread.cc(221)] Waited 33 ms for network service
Traceback (most recent call last):
File “C:\Users\mihai\AppData\Local\Programs\Python\Python37-32\Scripts\maps-cookie-getter-script.py”, line 11, in
load_entry_point(‘mapscookiegettercli==0.1.1’, ‘console_scripts’, ‘maps-cookie-getter’)()
File “c:\users\mihai\appdata\local\programs\python\python37-32\lib\site-packages\mapscookiegettercli\mapscookiegettercli.py”, line 92, in main
getter.run()
File “c:\users\mihai\appdata\local\programs\python\python37-32\lib\site-packages\mapscookiegettercli\library\cookiegetter.py”, line 177, in run
while LOGGED_IN_HEURISTIC not in driver.page_source:
File “c:\users\mihai\appdata\local\programs\python\python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py”, line 679, in page_source
return self.execute(Command.GET_PAGE_SOURCE)[‘value’]
File “c:\users\mihai\appdata\local\programs\python\python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py”, line 321, in execute
self.error_handler.check_response(response)
File “c:\users\mihai\appdata\local\programs\python\python37-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py”, line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: chrome not reachable
(Session info: chrome=75.0.3770.90)

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)