Google Maps location sharing - New thread

Ok I got all needed debugging activated:

homeassistant.components.device_tracker: debug
locationsharinglib: debug

and now I got the needed debugs in the logs. The library is getting the people within its call but it seems, that it cant handle it in the right way. I modified parts of the result (removing names and so on, and prettyfied it to json, but nothing else)

2018-07-12 14:08:32 DEBUG (SyncWorker_17) [locationsharinglib.Service] )]}’

[
   [
      [
         [
            "115647524841220717455",
            "https://lh4.googleusercontent.com/xxx/photo.jpg",
            null,
            "First Person",
            null,
            null,
            null,
            "0ahUKEwj53rfGw5ncAhVGzaQKHbI3AOEQvDgIBCgA"
         ],
         [
            null,
            [
               null,
               9.1471518,
               48.9991617
            ],
            1531396898966,
            104,
            "Correct name of the location",
            null,
            "DE",
            7200000
         ],
         1,
         2,
         "0ahUKEwj53rfGw5ncAhVGzaQKHbI3AOEQu4IBCAMoAQ",
         null,
         [
            "115647524841220717455",
            "https://lh4.googleusercontent.com/xxx/photo.jpg",
            "First Person",
            "First Person"
         ],
         1
      ],
      [
         [
            "116671884344703922115",
            "https://lh4.googleusercontent.com/xxx/photo.jpg",
            null,
            "Second Person",
            null,
            null,
            null,
            "0ahUKEwj53rfGw5ncAhVGzaQKHbI3AOEQvDgIECgA"
         ],
         [
            null,
            [
               null,
               9.2337673,
               49.1821549
            ],
            1531396970789,
            15,
            "Correct name of the location",
            null,
            "DE",
            7200000
         ],
         1,
         2,
         "0ahUKEwj53rfGw5ncAhVGzaQKHbI3AOEQu4IBCA8oAg",
         null,
         [
            "116671884344703922115",
            "https://lh4.googleusercontent.com/xxx/photo.jpg",
            "Second Person",
            "Second Person"
         ],
         1
      ],
      [
         [
            "103752248718793663566",
            "https://lh6.googleusercontent.com/xxx/photo.jpg",
            null,
            "Third Person",
            null,
            null,
            null,
            "0ahUKEwj53rfGw5ncAhVGzaQKHbI3AOEQvDgIGygA"
         ],
         [
            null,
            [
               null,
               9.1282772,
               48.9917452
            ],
            1531394165997,
            15,
            "Correct name of the location",
            null,
            "DE",
            7200000
         ],
         1,
         2,
         "0ahUKEwj53rfGw5ncAhVGzaQKHbI3AOEQu4IBCBooAw",
         null,
         [
            "103752248718793663566",
            "https://lh6.googleusercontent.com/xxx/photo.jpg",
            "Third Person",
            "Third Person"
         ],
         1
      ],
      [
         [
            "102736582871329949853",
            "https://lh4.googleusercontent.com/xxx/photo.jpg",
            null,
            "4th Person",
            null,
            null,
            null,
            "0ahUKEwj53rfGw5ncAhVGzaQKHbI3AOEQvDgIKCgA"
         ],
         null,
         null,
         null,
         "0ahUKEwj53rfGw5ncAhVGzaQKHbI3AOEQu4IBCCcoBA",
         null,
         [
            "102736582871329949853",
            "https://lh4.googleusercontent.com/xxx/photo.jpg",
            "4th Person",
            "4th Person"
         ],
         1
      ]
   ],
   null,
   "0ahUKEwj53rfGw5ncAhVGzaQKHbI3AOEQ8ZABCAE",
   "wERHW_n-DMaakwWy74CIDg",
   null,
   null,
   "CN6JndoFEAEaqgIAKcPHfFf4A9f+Lrp96M25z7Vg7RKMlPINIcUaPRAhu48IlkwbdR6tIYYdERED5kOhfAOw8FBZoim2mOwQxHCCMQVMB+O1ebUXP7/872AkecrzD1jQn8RzGAOoQhgJf8zXkIO3TnQ9Zyf2j08fO3StXMh9q1F+O/xzL3mU7hpyY3wLccQMdWhAsKYN8YHByJEdcupomEBFaD8P9xie2WvCMxpR1HbXr4EjhOF4m7K+JHWxT3urFv7dbpqrmxGPXfuKGt4cMSjDB5y
LmC+uTmRXnNPUlzJmK2F5BDQ262uAqtjtgdz+2fwMIzvUa4Bp/7LwdVF3CFSbgnWjntHBFbuxwKmBthj2XXE0vWllgbq6nPEb8NEfiGrImpRa0O3gtvlt/eNzsygg2O61",
   5,
   1531397312880,
   null,
   null,
   [
      1,
      [
         [
            [
               30000,
               60000
            ],
            null,
            3600000
         ]
      ],
      null,
      1
   ]
]

2018-07-12 14:08:32 DEBUG (SyncWorker_17) [locationsharinglib.Service] Could not load people, response:

and then the respone again. So its the code line

people = [Person(info) for info in output[0]]

producing the problem. Now I really need some help from the developers…

Regards

Ok I found the error now. As soon a device is offline for some time the Datetime / timestamp is not set in the output but the library (locationlibsharing) is still trying to convert it into a number/timestamp. This causes an TypeError even using the newset locationlibsharing 2.0.11.
The current used library has even more problems as it tries to convert other unset fields too.
It can be fixed by modifying the library only!
So I will need a local locationlibsharing and fix it there. Or “you” fix it and fix home assistant.

1 Like

Good job Luke. Following your trouble shooting help me connect a bunch of dots. Slang for I learned a lot. :slight_smile:

I could not understand why if you could connect, why it would not update. What is different about your “google maps” that is different than mine? Could it be that different devices update differently? But the map then would have to render it differently. You have my curiosity up. I posted the location to the code below. I glanced at the code, keep in mind you are more familiar with it than I, are you seeing the “InvalidData” exception?
I could be in the wrong area, to me looks like the work is done in _populate function.
snippet:

class Person(object):  # pylint: disable=too-many-instance-attributes
    """A person sharing its location as coordinates"""

    def __init__(self, data):
        logger_name = u'{base}.{suffix}'.format(base=LOGGER_BASENAME,
                                                suffix=self.__class__.__name__)
        self._logger = logging.getLogger(logger_name)
        self._id = None
        self._picture_url = None
        self._full_name = None
        self._nickname = None
        self._latitude = None
        self._longitude = None
        self._timestamp = None
        self._accuracy = None
        self._address = None
        self._country_code = None
        self._populate(data)

    def _populate(self, data):
        try:
            self._id = data[6][0]
            self._picture_url = data[6][1]
            self._full_name = data[6][2]
            self._nickname = data[6][3]
            self._latitude = data[1][1][2]
            self._longitude = data[1][1][1]
            self._timestamp = data[1][2]
            self._accuracy = data[1][3]
            self._address = data[1][4]
            self._country_code = data[1][6]
        except IndexError:
            self._logger.debug(data)
            raise InvalidData

https://github.com/costastf/locationsharinglib
Also I found this issue https://github.com/costastf/locationsharinglib/issues/26 The last line says Pull Request fixed issue. Must be something different.
https://github.com/costastf/locationsharinglib/pull/25/commits/e0cb8e6afd2269c7cadbdcc77b33b0a8ada7584a
Also, I started to reply but got sidetracked, you can run the locationlibsharing from the command line. You might try the latest branch, although the description does not seem to relate to your issue.

The error is located on the string representation methods used in the Person class. They try to convert Null values to dates and integers and so on. I downloaded newest locationsharinglib inside my ssh addon container and debugged with a small self made piece of code. Now i placed the locatiobsharinglib in my config folder below deps together with a .version and modified the local google-maps component to have requirement to that newest version. All works fine now. The wrong of the 4th person with missing timestamp and no current location just gets ignored now.

Still facing some issue on Google Location Sharing

From the log, I can see that all the 3 google account that shares location with my google account are tracked perfectly.

But in HA none is shown.
I can see an error
[locationsharinglib.Service] Could not load people, response:

What can be the issue?

@lweberru I’m facing an issue like o equal to yours.
What was your solution?

BTW, I’m on HASSIO so I have very limited possibilities… :thinking:

Thanks

018-07-18 12:22:07 DEBUG (SyncWorker_16) [locationsharinglib.Service] )]}'
[[[["xxxxxxxx","https://lh3.googleusercontent.com/-xxxxxxxx/mo/photo.jpg",null,"NAME-A ",null,null,null,"xxxxxxx"]
,[null,[null,00.000000,11.1111111]
,xxxxxxxxx,"street-location",null,"IT",7200000]
,1,2,"xxxxxxxxxx",null,["xxxxxxxxx","https://lh3.googleusercontent.com/-xxxxxxxx/mo/photo.jpg","NAME-A","NAME-A"]
,1]
,[["yyyyyyyyyy","https://lh6.googleusercontent.com/-yyyyyyyyyyy/mo/photo.jpg",null,"NAME-B",null,null,null,"yyyyyyyyyy"]
,[null,[null,22.2222222,33.3333333]
,yyyyyy,"street-location",null,"IT",7200000]
,1,1,"yyyyyyyyy",null,["yyyyyyy","https://lh6.googleusercontent.com/-yyyyyyyyyy/mo/photo.jpg","NAME-B","NAME-B"]
,0]
,[["zzzzzzzzzzz","https://lh6.googleusercontent.com/-zzzzzzzzz/mo/photo.jpg",null,"NAME-C",null,null,null,"zzzzzzzzzzz"]
,null,null,null,"zzzzzzzzz",null,["zzzzzzzz","https://lh6.googleusercontent.com/-zzzzzzzzz/mo/photo.jpg","NAME-C","NAME-C"]
,1]
]
,null,"xxxxx","xxxx",null,null,"xxxxxx/xxxxxx/xxxxxxx/xxxxxx/xxxxxx+xxxxxx/xxxx/xx/+xx/+xxxxx/xxxx+xxxxx+xxxx+xxxxx",xxxxx,[xxxxx,[null,[null,00.00000,11.111111]
,xxxxxx,"street-location",null,"IT",7200000]
]
,null,[1,[[[30000,60000]
,null,3600000]
,[[30000,60000]
,null,null,1]
]
,null,1]
]

2018-07-18 12:22:07 DEBUG (SyncWorker_16) [locationsharinglib.Service] Could not load people, response: [[[['xxxxxxxx', 'https://lh3.googleusercontent.com/-xxxxxxxxxx/mo/photo.jpg', None, 'NAME-A.', None, None, None, 'xxxxxxx'], [None, [None, 00.00000, 11.1111], xxxxx, 16, 'street-location', None, 'IT', 7200000], 1, 2, 'xxxxxx', None, ['xxxxxx', 'https://lh3.googleusercontent.com/-xxxxxxxxx/mo/photo.jpg', 'NAME-A', 'NAME-A'], 1], [['yyyyyyyyyyy', 'https://lh6.googleusercontent.com/-yyyyyyyyy/mo/photo.jpg', None, 'NAME-B', None, None, None, 'yyyyyyyyyy'], [None, [None, 22.22222, 33.333333], yyyyyyyy, 92, "street-location", None, 'IT', 7200000], 1, 1, 'yyyyyyyyy', None, ['yyyyyyyy', 'https://lh6.googleusercontent.com/-yyyyyyyyy/mo/photo.jpg', 'NAME-B', 'NAME-B'], 0], [['zzzzzzzzz', 'https://lh6.googleusercontent.com/-zzzzzzzz/mo/photo.jpg', None, 'NAME-C', None, None, None, 'zzzzzzzz'], None, None, None, 'zzzzzzz', None, ['zzzzzz', 'https://lh6.googleusercontent.com/-zzzzzz/mo/photo.jpg', 'zzzzz', 'zzz'], 1]], None, 'zzzzzz', 'zzzzz', None, None, 'zzzzz/zzzzz/zzzzzz/zzz/zz+zz/zzz/zzz/+zz/+zzzzz/zzzz+zzz+zz+zzzz', 5, zzzz, [zzz, [None, [None, 44.44444, 55.5555], zzzzz, 33, 'zzzzzzzz', None, 'IT', 7200000]], None, [1, [[[30000, 60000], None, 3600000], [[30000, 60000], None, None, 1]], None, 1]]

One of your tracked accounts is missing a must have data, which results in a failing data type converstion within the library. To fix it you need to work with the newest locationsharinglib. For that you need to have a local custom component of the google_maps.py with a changed requirement setting:

1.) place a copy of the goog_maps.py into /config/custom_components/device_tracker
2.) change requirements in the file to:

REQUIREMENTS = ['locationsharinglib==2.0.11']

If it is still not working you can also make a copy of the library and modify it. Let me know if it is not working, than I tell you what to modify there.

Regards
Lukas

Thanks @lweberru

Where I can find the goog_maps.py?

Take the official source from git:

https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/device_tracker/google_maps.py

Regards

1 Like

@lweberru After placing the google_maps.py in /config/custom_components/device_tracker with the requirements files changed, rebooted, nothing changed, same error.

I can have a local copy of the library even if I am on HASSIO?

Thanks again

Do you have the note, that you are using a local copy of this component like this?

2018-07-18 16:07:56 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.

Do you see home assistant downloading the new locationlibshared version during docker start? Think this should be visible via
hassio su logs
if this is the case, than I would install a local copy of the locationsharinglib into the directory:

/config/deps/lib/python3.6/site-packages/locationsharinglib

place the following files there:
locationsharinglib.py
locationsharinglibexceptions.py
.VERSION

you get the sources from

I modified the file like the following:

replace

return datetime.fromtimestamp(int(self.timestamp) / 1000)

with

try:
  return datetime.fromtimestamp(int(self.timestamp) / 1000)
except (IndexError, TypeError):
  return 0

but I am no python developer…

I can see the message regarding usage of local copy.

I already have a locationsharinglib folder, actually I have two

13

inside the first folder:

23

The date inside the file is the same as the one you linked:
__date__ = '''2017-12-24'''

should I modify as you wrote in the message?

What about the other folder? Should I remove it?

Thanks

I am still not really and fully familar with home assistant architecture and python, so perhaps someone else can say how exactly these folder and file structure should look like? Dont want to share my not existing knowledge :smile:

Thanks @lweberru

Strange thing is that I have set up a new fresh install of latest version of HA without adding any device, except the ones discovered, without modifying any config file, except adding

device_tracker:
  - platform: google_maps
    username: MY_USERNAME
    password: MY_PASSWORD

and I still get no tracking.

In known_devices.yaml I get

google_maps_myemailgmailcom:
  hide_if_away: false
  icon:
  mac:
  name: google maps myemailgmailcom
  picture:
  track: true

instead of the address to be tracked.

Hey, not sure if this will help anyone else but about a week ago i started using the google location tracking and all was great then all of a sudden It just stopped working,

After a bit of searching, i came across this thread and followed the steps from here down:

I’ve added the custom component, added the debug logging which gave me the error of “Could not load people, response:”

After a quick google I came across this:

Which led me to just trying jedi7’s pull request

(Fix problem with missing location by jedi7 · Pull Request #25 · costastf/locationsharinglib · GitHub)

I’ve just tried it and it’s working perfectly for me .

I may have repeated someone elses advice so apologies if i have but it fixed things for me and thought it might help others.

Hey, I have google maps set up in my HA and it seems to be working ok. Does anyone know if you can see up a work zone? I tried setting one up in the google maps app, but it doesn’t show at work in HA.

Zones are defined within HA itself, look documentation about zones. There is also a configure option.

Got it, thanks.

Thanks radeon for the tip. My kids went out of state for a while where they have poor to no cell signal. Knowing about this apparent bug of phones reporting bad location info and it keeping all/some Google Maps devices from being tracked, I unshare my kids phone location to my HA Google account used for device tracking. This fixed the issue for my phone and it’s being tracked again now. I could see in the logs that the 3 devices were reporting location info, but my kids info was formatted oddly compared to my phone’s info.

@radeon i am missing something here. Placed the file “google_maps.py” modified it but nothing happened
Where did you put the jedy .py script ?

I was having the same issues and I finally resolved it by doing the following:
Create a new gmail account for tracking and have your friends and family allow tracking on that account. DO THIS BEFORE YOU PROCEED ANY FURTHER!

In the /config directory delete file:

.google_maps_location_sharing.cookies

Delete any entries in known_devices.yaml referring to google_maps (or just delete the entire file)

Insert ONLY the google account you set up to do the tracking in your configuration.yaml like this:

 #Tracking stuff
 device_tracker:
   - platform: google_maps
     username: [email protected]
     password: ########
     track_new_devices: true

Reboot

In your groups.yaml create something like this:

awesome_people:
  name: Awesome People
  view: no
  entities:
    - device_tracker.google_maps_xxxxxxxxxxxxxxxxxxxxxxx
    - device_tracker.google_maps_xxxxxxxxxxxxxxxxxxxxxxx

(those x’s will be a unique id you will see in the known_devices.yaml file)

Clean up:
You may want to go back into the known_devices.yaml file and put a usable name in the name: field.
After 3 days of pulling my hair out, I fixed myself a cocktail and smiled.