Google Maps location sharing - New thread

Same here, very annoying. But that´s on the Google side, so there´s nothing to be done about it…

yea we need to keep commenting on that bug I linked. 2.0.7 was supposed to fix this. If you guys see the error make sure to comment on the bug with the error message so it can be fixed. I personally have not seen it since I switched to 2.0.7.

For me it is still not working with Hassio 0.71.0. I also removed all these custom deps files and again removed google cache and so on and again I am not even getting error messages. So I need a way to debug the service. I think it is crashing somehow without a word. Any help is welcome.

Luke, if device.tracker google entries are showing up in your state and your shared accounts are showing on the map of the HA google account. It should work. I don’t see that as a configuration issue. Could it be a firewall issue? Just thinking outside the box.

Removed all the custom codes and updated to 0.71.0.

Got the following: I will wait few hours… and restart again.

Tue Jun 12 2018 10:00:02 GMT-0400 (EDT)

Error setting up platform google_maps
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/urllib3/connection.py", line 141, in _new_conn
    (self.host, self.port), self.timeout, **extra_kw)
  File "/usr/lib/python3.6/site-packages/urllib3/util/connection.py", line 60, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/lib/python3.6/socket.py", line 745, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Try again

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 601, in urlopen
    chunked=chunked)
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 346, in _make_request
    self._validate_conn(conn)
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 850, in _validate_conn
    conn.connect()
  File "/usr/lib/python3.6/site-packages/urllib3/connection.py", line 284, in connect
    conn = self._new_conn()
  File "/usr/lib/python3.6/site-packages/urllib3/connection.py", line 150, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x70e4a590>: Failed to establish a new connection: [Errno -3] Try again

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/requests/adapters.py", line 440, in send
    timeout=timeout
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 639, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/lib/python3.6/site-packages/urllib3/util/retry.py", line 388, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='accounts.google.com', port=443): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x70e4a590>: Failed to establish a new connection: [Errno -3] Try again',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/components/device_tracker/__init__.py", line 183, 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 41, in setup_scanner
    scanner = GoogleMapsScanner(hass, config, see)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/device_tracker/google_maps.py", line 59, in __init__
    hass.config.path(CREDENTIALS_FILE))
  File "/usr/lib/python3.6/site-packages/locationsharinglib/locationsharinglib.py", line 367, in __init__
    cookies_file=cookies_file)
  File "/usr/lib/python3.6/site-packages/locationsharinglib/locationsharinglib.py", line 193, in __init__
    if cookies_file and self._validate_cookie(cookies_file):
  File "/usr/lib/python3.6/site-packages/locationsharinglib/locationsharinglib.py", line 215, in _validate_cookie
    response = self._session.get(self._login_url)
  File "/usr/lib/python3.6/site-packages/requests/sessions.py", line 521, in get
    return self.request('GET', url, **kwargs)
  File "/usr/lib/python3.6/site-packages/requests/sessions.py", line 508, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3.6/site-packages/requests/sessions.py", line 618, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3.6/site-packages/requests/adapters.py", line 508, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='accounts.google.com', port=443): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x70e4a590>: Failed to establish a new connection: [Errno -3] Try again',))

BTW: my tracker is now showing as google_map_myemailaddress: without the @sign and “.”

Update: 0.71.0 works fine tracker working properly, rebooted and no more errors. - June 13, 2018

There is no firewall outgoing to the internet.If I remove the known_devices entries. I should normally get new ones, but I dont. And again, I am mostly wondering, that I dont get any error messages. So a chance to debug would be the only way forward.

New bug now. I just reinstalled Hassio (0.71), and I can´t get the shared account´s location, anly the secondary account´s. No error message recorded, and deleting the cookie doesn´t fix the problem.

Anyone with the same problem?

Hi

I’m getting too an issue on 0.72.1
In known_devices.yaml I see a google_maps_usernamegmail.com: instead of seeing google_maps_number:
The google_maps_usernamegmail: is the same email defined in the username: field in the device_tracker.
I tried removing the .google_maps_location_sharing.cookies and restarting Hassio, but no change…

Google maps is still not working for me. I think without tips to debug what the code is doing no chance. All manual doing works great and not one error message in any logs. The component just does not update the instances as it should.

I am on .72.1 and I have two trackers working. Do you still have the issue?

Someone else said that, is it working otherwise? If you log into the sharing account what do it say?

First step, log into the sharing account and see if the users are showing up. Then while you are there look at authorized devices and make sure you have approved hass. Then delete the cookie and reboot one more time. When you restart after deleting cookie, you will see an error about the cookie missing. That is ok, check and see if any of the tracker entities are there.

All of that tips i got endless times and tried it multiple times. Again manually is all working fine. But not within home assistant. It is just not updating the tracked instances as it should. What is needed is a way to see what the discovery is doing with logger.debug messages or so.

@penright
nope, it’s not working in HA.
I will try to go back to 0.69.1 that, as I remember, was the last version where it was working.
I’ve tried to delete all occurencies, related to google maps, from known_devices.yaml then remove the .google_maps_location_sharing.cookies from config folder, restart HA, but always the same.
I have two gmail addresses that shares their position with one of my gmail account that I use to define the google maps location sharing in HA.
What I get in known_devices.yaml is an entrance with google_maps_my_email_address instead of the ones that share location with me.

Sorry for my english, I hope is more clear than before.

Does it show up dev-state but the position does not update?

And if you log on to what I call the service account. The one that is shared to, and go to maps is it correct?

Right now I am on 72.1 and it is working for me. Are the entities showing in the dev-state?

No, not the entities that should be shown, the two that share position with my Gmail account, but just a google_maps entity with my Gmail account.

One last question and then it’s beyond my help. :slight_smile:
When you say, “just the google_map entity with the Gmail account”, I assume that is the google account that the users are sharing the location with. If you log into that user and go to maps. Do you see the shared users?
If that is working, it should work. Could there be any firewall issues?

Yes, correct, I can see the accounts who share locations with me from Android or Windows Google Maps.
I can see from computers or phones from the same network where HA is located.

If you are willing to try a shot in the dark. This morning I was trying to clean up my hass. I had a entity from owntrack that I could not get rid of it. Somewhere I read mqtt could have cache the info, so I deleted my broker. Still had the entity. There is a known_device.yaml and yes, there was the entity. I deleted it and it was gone.
Maybe your known_device.yaml has something causing issues. I would back it up first, but if you delete any references to your tracker, and restart hass, maybe … I am reaching here, so standard disclaimer try at your own risk. :slight_smile:
Other than that I am tapped out.

1.) It does not show any dev-state. The instance exists but does not get “touched” at all.
2.) If i log on with a browser into my sharing service account. All works fine, so I can see all people there as it should.

I again deleted whole thing and reconfigured it (delete cookie file and entries in known_devices and restarted). I also copied the google_maps.py to local custom_components and added some debug lines to see when he logs in and when he discovers. All I get in the logs is the following:

2018-07-12 11:15:20 WARNING (MainThread) [homeassistant.loader] You are using a custom component for device_tracker.google_maps which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2018-07-12 11:17:04 INFO (MainThread) [homeassistant.components.device_tracker] Setting up device_tracker.google_maps
2018-07-12 11:17:05 WARNING (SyncWorker_18) [custom_components.device_tracker.google_maps] google_maps: logging in with user xxx and password xxx
2018-07-12 11:17:05 ERROR (SyncWorker_18) [locationsharinglib.Service] Could not open pickle file, either file does not exist or no read access.

After that no further note even I modified the update_info definition like that:

def _update_info(self, now=None):
    for person in self.service.get_all_people():
        try:
            dev_id = 'google_maps_{0}'.format(slugify(person.id))
            _LOGGER.warning("google_maps: got dev_id "+dev_id)
            _LOGGER.warning("google_maps: got name "+person.full_name)
        except TypeError:
            _LOGGER.warning("No location(s) shared with this account")
            return

        attrs = {
            ATTR_ADDRESS: person.address,
            ATTR_FULL_NAME: person.full_name,
            ATTR_ID: person.id,
            ATTR_LAST_SEEN: person.datetime,
            ATTR_NICKNAME: person.nickname,
        }
        self.see(
            dev_id=dev_id,
            gps=(person.latitude, person.longitude),
            picture=person.picture_url,
            source_type=SOURCE_TYPE_GPS,
            gps_accuracy=person.accuracy,
            attributes=attrs,
        )

So the method self.service.get_all_people() looks like it does just nothing. This function is defined in locationsharinglib.py and calling get_shared_people()
get_shared_people looks like this:

def get_shared_people(self):
    """Retrieves all people that share their location with this account"""
    output = ''  # making pycharm introspection happy
    try:
        output = self._get_data()
        people = [Person(info) for info in output[0]]
    except (IndexError, TypeError):
        self._logger.debug('Could not load people, response: %s', output)
        return []
    return people

The error there seems to be a “debug” and not an error. So how can I add debug function there?

Then the get_data is the following:

def _get_data(self):
    payload = {'authuser': 0,
               'hl': 'en',
               'gl': 'us',
               # pd holds the information about the rendering of the map and
               # it is irrelevant with the location sharing capabilities.
               # the below info points to google's headquarters.
               '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')}
    url = 'https://www.google.com/maps/preview/locationsharing/read'
    response = self._session.get(url, params=payload)
    self._logger.debug(response.text)
    try:
        data = json.loads(response.text.split("'", 1)[1])
    except (ValueError, IndexError, TypeError):
        self._logger.exception('Unable to parse response :%s',
                               response.text)
        data = ['']
    return data

Here my question would be, how can I test this rest webservice call using the cookie file by curl?

Any help is welcome