Google maps location sharing in latest beta

Not sure where the best place to post this is since there isn’t a 0.67 beta thread open yet.

Google maps location sharing doesn’t appear to be working. This the config I have

- platform: google_maps
  username: my_email
  password: my_password

I get the following error trying to use the google maps location sharing.

2018-04-08 00:26:05 ERROR (SyncWorker_7) [locationsharinglib.Service] Caught exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/locationsharinglib/locationsharinglib.py", line 284, in _get_data
    people = [Person(info) for info in output[0]]

I’m not running the 0.67 beta yet, but i did copy the googlemaps.py into my custom_configuration folder on HASSIO and setup the device_tracker the way you have it.
I did get some errors the first time I started home-assistant that it could find the locationsharinglib, but after a second restart it seems to be working fine.
The problem I am facing now is that the googlemaps location only seems to update when I restart home-assistant, and it is not very accurate.

I’m seeing the same thing, currently on 0.67 stable. I created a brand new Google account without 2FA. I allowed HA to log in, as initially Google did prevent the sign in. I also restarted the instance a few time and tried removing the cookies that were in .google_maps_location_sharing.cookies.

I’m running on 0.67
I tried to set up the Google Maps Location Sharing
I’m running on hassbian

When I’m running directly from python

from locationsharinglib import Service
service = Service("[email protected]", "password", "google_maps_location_sharing.conf")

seems to do the login
when I restart hass
I’m getting

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

Its been working fine for me after upgrading to 0.67 stable - no errors in the logs and the location seems to be updating now at regular intervals.
I get a bit of location drift, but I blame google for that one.

Ill run with both gmaps and gps logger for a few weeks and see.

I’m currently using GPSlogger as well and would be interested in your results. Would be nice if you could share them as soon as you see trends on what works better.

I was using Zanzito which is similar to GPSlogger. The google maps component has been a lot slower updateting location than Zanzito unfortunately.

I tried again to clear the pycache
I used the python to create google_maps_location_sharing.conf file
its under /home/homeassistant/.homeassistant
And when i restart home assistant i get

Apr 16 11:55:46 hassbian hass[2110]: ERROR:homeassistant.components.device_tracker:Error setting up platform google_maps

Apr 16 11:55:46 hassbian hass[2110]: Traceback (most recent call last):

Apr 16 11:55:46 hassbian hass[2110]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/__init__.py", line 184, in async_setup_platform

Apr 16 11:55:46 hassbian hass[2110]:     disc_info)

Apr 16 11:55:46 hassbian hass[2110]:   File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__

Apr 16 11:55:46 hassbian hass[2110]:     yield self  # This tells Task to wait for completion.

Apr 16 11:55:46 hassbian hass[2110]:   File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup

Apr 16 11:55:46 hassbian hass[2110]:     future.result()

Apr 16 11:55:46 hassbian hass[2110]:   File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result

Apr 16 11:55:46 hassbian hass[2110]:     raise self._exception

Apr 16 11:55:46 hassbian hass[2110]:   File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run

Apr 16 11:55:46 hassbian hass[2110]:     result = self.fn(*self.args, **self.kwargs)

Apr 16 11:55:46 hassbian hass[2110]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/google_maps.py", line 36, in setup_scanner

Apr 16 11:55:46 hassbian hass[2110]:     scanner = GoogleMapsScanner(hass, config, see)

Apr 16 11:55:46 hassbian hass[2110]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/google_maps.py", line 54, in __init__

Apr 16 11:55:46 hassbian hass[2110]:     hass.config.path(CREDENTIALS_FILE))

Apr 16 11:55:46 hassbian hass[2110]:   File "/srv/homeassistant/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py", line 184, in __init__

Apr 16 11:55:46 hassbian hass[2110]:     if cookies_file and self._validate_cookie(cookies_file):

Apr 16 11:55:46 hassbian hass[2110]:   File "/srv/homeassistant/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py", line 209, in _validate_cookie

Apr 16 11:55:46 hassbian hass[2110]:     raise InvalidCookies(message)

Apr 16 11:55:46 hassbian hass[2110]: locationsharinglib.locationsharinglibexceptions.InvalidCookies: The cookies provided do not provide a valid session.Please authenticate normally and save a valid session again

Apr 16 11:55:46 hassbian hass[2110]: INFO:homeassistant.core:Bus:Handling <Event system_log_event[L]: message=Error setting up platform google_maps, timestamp=1523868946.7904654, source=components/device_tracker/google_maps.py, level=ERROR, exception=Traceback (most recent call last):

Apr 16 11:55:46 hassbian hass[2110]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/__init__.py", line 184, in async_setup_platform

Apr 16 11:55:46 hassbian hass[2110]:     disc_info)

Apr 16 11:55:46 hassbian hass[2110]:   File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__

Apr 16 11:55:46 hassbian hass[2110]:     yield self  # This tells Task to wait for completion.

Apr 16 11:55:46 hassbian hass[2110]:   File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup

Apr 16 11:55:46 hassbian hass[2110]:     future.result()

Apr 16 11:55:46 hassbian hass[2110]:   File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result

Apr 16 11:55:46 hassbian hass[2110]:     raise self._exception

Apr 16 11:55:46 hassbian hass[2110]:   File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run

Apr 16 11:55:46 hassbian hass[2110]:     result = self.fn(*self.args, **self.kwargs)

Apr 16 11:55:46 hassbian hass[2110]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/google_maps.py", line 36, in setup_scanner

Apr 16 11:55:46 hassbian hass[2110]:     scanner = GoogleMapsScanner(hass, config, see)

Apr 16 11:55:46 hassbian hass[2110]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/google_maps.py", line 54, in __init__

Apr 16 11:55:46 hassbian hass[2110]:     hass.config.path(CREDENTIALS_FILE))

Apr 16 11:55:46 hassbian hass[2110]:   File "/srv/homeassistant/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py", line 184, in __init__

Apr 16 11:55:46 hassbian hass[2110]:     if cookies_file and self._validate_cookie(cookies_file):

Apr 16 11:55:46 hassbian hass[2110]:   File "/srv/homeassistant/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py", line 209, in _validate_cookie

Apr 16 11:55:46 hassbian hass[2110]:     raise InvalidCookies(message)

Apr 16 11:55:46 hassbian hass[2110]: locationsharinglib.locationsharinglibexceptions.InvalidCookies: The cookies provided do not provide a valid session.Please authenticate normally and save a valid session again

Apr 16 11:55:46 hassbian hass[2110]: >

Can anyone help me with that ?

I got it to work but with a nasty workaround
Need to dig a bit more:
I edited the file /srv/homeassistant/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py

class Service(object):

    """An object modeling the service to retrieve locations"""

    def __init__(self, email, password, cookies_file=None):
        logger_name = u'{base}.{suffix}'.format(base=LOGGER_BASENAME,
                                                suffix=self.__class__.__name__)
        self._logger = logging.getLogger(logger_name)
        self._session = Session()
        self.email = email
        self.password = password
        self._login_url = 'https://accounts.google.com'
        cookies_file='/home/homeassistant/.homeassistant/google_maps_location_sharing.conf'
        # Try login with cookie
        if cookies_file and self._validate_cookie(cookies_file):
            return

And I added hard coded :
cookies_file='/home/homeassistant/.homeassistant/google_maps_location_sharing.conf'

Need to understand where to put that cookies file so I can remove that line

Looking at the component that path is passed to locationsharinglib here:

Which is defined as:

I noticed that when I restart the instance without removing the .cookies file it’ll throw:

2018-04-16 14:27:14 ERROR (MainThread) [homeassistant.components.device_tracker] 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 209, 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

Restarting after removing the .cookies file throws:

2018-04-16 14:32:34 ERROR (SyncWorker_18) [locationsharinglib.Service] Could not open pickle file, either file does not exist or no read access.
2018-04-16 14:32:36 ERROR (SyncWorker_18) [locationsharinglib.Service] Caught exception
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/locationsharinglib/locationsharinglib.py", line 284, in _get_data
    people = [Person(info) for info in output[0]]
TypeError: 'NoneType' object is not iterable

I’m assuming the first login request fails without it noticing the failure. That would in turn cause errors fetching location data and also cause a login using the cached cookies to fail. Trouble is, I’m not sure how to reset the whole thing and start over. It seems something besides the .cookies file is cached.

EDIT: Created a brand new Google account and I’m getting the same thing. I’m using Hass.io on a RPi 2, if that matters.

I’m having the exact same problem, any luck on a fix?

GMAPS vs GPSLOGGER Update
GPSLogger updates quicker and is more accurate.
Also i get these errors every couple seconds periodically throughout the day.

Caught exception
Traceback (most recent call last):
  File "/config/deps/lib/python3.6/site-packages/locationsharinglib/locationsharinglib.py", line 283, in _get_data
    output = json.loads(response.text.split("'", 1)[1])
IndexError: list index out of range
1 Like

I’m getting this cosy error and no idea why. It worked for hours now after a restart it does not.

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/__init__.py", line 184, in async_setup_platform
    disc_info)
  File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/.homeassistant/custom_components/device_tracker/google_maps.py", line 33, in setup_scanner
    scanner = GoogleMapsScanner(hass, config, see)
  File "/home/homeassistant/.homeassistant/custom_components/device_tracker/google_maps.py", line 53, in __init__
    self._update_info()
  File "/home/homeassistant/.homeassistant/custom_components/device_tracker/google_maps.py", line 65, in _update_info
    for person in self.service.get_all_people():
  File "/srv/homeassistant/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py", line 287, in get_all_people
    return self._get_data()
  File "/srv/homeassistant/lib/python3.5/site-packages/cachetools/__init__.py", line 46, in wrapper
    v = func(*args, **kwargs)
  File "/srv/homeassistant/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py", line 278, in _get_data
    output = json.loads(response.text.split("'")[1])
  File "/usr/lib/python3.5/json/__init__.py", line 319, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.5/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.5/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)