Google Maps location sharing

I tested this with hass.io 0.67beta0 and it’s updating super fine. but how can I change the identifier from device_tracker.google_maps_ to something customized like device_tracker.disrupted? It didn’t create an entry in entity_registry.yaml and if I change it in known_devices.yaml I will end up with a new entry.

If you go to customize, find the entity and create a new attribute friendly_name and put what you want in the value…

Can anyone help me get this working in Hassio? I’m running the latest version at the time of writing, 66.1, but it’s just not working. I use 2FA normally, and so I generated an app specific password but when I do that it throws an invalid password related error in the log.

that doesn’t help me to change the identifier though, only the frontend name.

I’d suggest waiting a few days because it’s merged already and will be in the upcoming 0.67.0 release

2 Likes

Thanks for all your work on this! If we are using this as a custom component, will we have to do anything before upgrading to 0.67?

This seems to work well most of the time (I used the custom component before, and then 0.67 beta), but every so often I notice if I visit google maps from any device on my network (ie my mobile), I have to do a captcha to proceed because google says it detected unusual activity from my IP.

Is this expected? Anyone else getting the same?

I just removed the custom component from my setup (using hassio) and restarted HA. Seemed to work fine

Just trying out Hass.io on a fresh install. Tried to add the device tracking for google maps and I get this.
image

I just noticed that today, and yes I guess it is expected since google registers your ip as the one that your third party account uses to access the shares and it reaches it every few seconds, so when another account gets accessed by the same ip it triggers Google’s security. As long as they don’t block the initial account with captcha I guess we will have to live with this.

Can the interval it checks the location be reduced? Maybe an option in a future release?

My thoughts were it is getting flagged due the the number of queries, not the different accounts? I mean, we could have 5 people in the house accessing google services and therefore coming from the same IP and have no issues. I think an IP hitting the google services every few seconds is what is getting flagged as unusual, because its pretty obvious its automated vs a user doing it. But I could be wrong :slight_smile:

I just treid the new component an am running into an error, when I try ti share the location of more than one devices.
With one device everything is fine, but when I add the second I get the following error:

2018-04-14 18:57:52 ERROR (MainThread) [homeassistant.core] Error doing job: Future exception was never retrieved
Traceback (most recent call last):
File “/usr/lib/python3.5/concurrent/futures/thread.py”, line 55, in run
result = self.fn(*self.args, **self.kwargs)
File “/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/components/device_tracker/google_maps.py”, line 67, in _update_info
for person in self.service.get_all_people():
File “/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py”, line 292, in get_all_people
return self._get_data()
File “/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/cachetools/init.py”, line 46, in wrapper
v = func(*args, **kwargs)
File “/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py”, line 283, in _get_data
output = json.loads(response.text.split(“'”, 1)[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)

EDIT
It seems not to be related to the number of shared locations. I reduced it back to the initial one device, but am still getting the same error-message.
Unter the Device Activity Page from Google is nothing special.

Same here worked fine with one user then added a second now it does the same as yours. Can’t get it working at all now.

I think I found the culprit.
Whe I call the url in my browser, that is called by the locationsharing library,
https://www.google.com/maps/preview/locationsharing/read
then Google thinks, I might be a bot and presents me a captcha.
I guess that is what happens to the script as well.


Any idea how to solve this or if this even is the culprit?

It started working again for about 10 minutes, now I get a new error:-

Error doing job: Future exception was never retrieved

Traceback (most recent call last):
File “/usr/lib/python3.5/concurrent/futures/thread.py”, line 55, in run
result = self.fn(*self.args, **self.kwargs)
File “/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/components/device_tracker/google_maps.py”, line 67, in _update_info
for person in self.service.get_all_people():
File “/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py”, line 292, in get_all_people
return self._get_data()
File “/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/cachetools/init.py”, line 46, in wrapper
v = func(*args, **kwargs)
File “/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py”, line 283, in _get_data
output = json.loads(response.text.split("’", 1)[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)

What happens in your Browser when you try to open https://www.google.com/maps/preview/locationsharing/read

I played a little bit around and tried it with a testscript from here Usage — locationsharinglib 5.0.3 documentation
Then I got the security warning in the Google Account and could dismiss it.
After that I am getting this error:

2018-04-14 21:55:29 ERROR (Thread-12) [locationsharinglib.Service] Caught exception
Traceback (most recent call last):
File “/srv/homeassistant/homeassistant_venv/lib/python3.5/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 have set up one account that shares his location with this account. When I run my testscript I get results.

I have no idea what to look for…

It seems like I found a fix for this.
I am running a manually installation version in virtualenv.
In my case the File to edit is located under
/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/components/device_tracker/
In the google_maps.py file the used version for the locationsharinglib is 0.4.0 while the newest release is 1.2.1
So I changed the file from
REQUIREMENTS = ['locationsharinglib==0.4.0']
to
REQUIREMENTS = ['locationsharinglib==1.2.1']

After a restart of homeassistant everything is working fine with to shared locations.

1 Like

The captcha Problem is coming back periodically…

400. That’s an error.

Your client has issued a malformed or illegal request. That’s all we know.