Google Maps location sharing

Do you mind helping me a bit?
I honestly have no idea how to use github. I understand that I must have the google_maps.py file in my homeassistant folder. I didnt find a file in your github so I copy-pasted the code into notepad++ and saved it by that name. <<<---- Did I do it right?
I saved the file in /usr/local/lib/python3.5/dist-packages/homeassistant/components/device_tracker
and I configured the configuration.yaml according to your documentation.
I clicked “check config” in home assistant to make sure everything is fine before I restart and this comes up in the error logs:

Traceback (most recent call last):
File “/usr/lib/python3.5/asyncio/tasks.py”, line 241, in _step
result = coro.throw(exc)
File “/usr/local/lib/python3.5/dist-packages/homeassistant/setup.py”, line 57, in async_setup_component
return (yield from task)
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/asyncio/tasks.py”, line 239, in _step
result = coro.send(None)
File “/usr/local/lib/python3.5/dist-packages/homeassistant/setup.py”, line 119, in _async_setup_component
conf_util.async_process_component_config(hass, config, domain)
File “/usr/local/lib/python3.5/dist-packages/homeassistant/config.py”, line 628, in async_process_component_config
platform = get_platform(domain, p_name)
File “/usr/local/lib/python3.5/dist-packages/homeassistant/loader.py”, line 104, in get_platform
return get_component(PLATFORM_FORMAT.format(domain, platform))
File “/usr/lib/python3.5/unittest/mock.py”, line 919, in call
return _mock_self._mock_call(*args, **kwargs)
File “/usr/lib/python3.5/unittest/mock.py”, line 985, in _mock_call
ret_val = effect(*args, **kwargs)
File “/usr/local/lib/python3.5/dist-packages/homeassistant/scripts/check_config.py”, line 179, in mock_get
module = MOCKS[‘get’]1
File “/usr/local/lib/python3.5/dist-packages/homeassistant/loader.py”, line 142, in get_component
module = importlib.import_module(path)
File “/usr/lib/python3.5/importlib/init.py”, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 986, in _gcd_import
File “”, line 969, in _find_and_load
File “”, line 958, in _find_and_load_unlocked
File “”, line 673, in _load_unlocked
File “”, line 669, in exec_module
File “”, line 775, in get_code
File “”, line 735, in source_to_code
File “”, line 222, in _call_with_frames_removed
File “/usr/local/lib/python3.5/dist-packages/homeassistant/components/device_tracker/google_maps.py”, line 7
+import logging
^
SyntaxError: invalid syntax

You need the file from my repository. You now copied the patch with the + signs. You should be able to find it in a subfolder of homeassistant/components.

Hi michaelarnauts

Need help, I’m still not clear on the installation instructions. I’m running my Home Assistant on a Raspberry Pi, can you please tell me which file / files content from your repository i need to place inside “google_maps.py” file located in “homeassistant/components/device_tracker/” folder ?

Agreed, the instructions to get things going are very confusing.

Any one manage to do it ?

This component is still in the process of being merged on the main HA codebase. To anyone that wants to use it before (consider it beta testing) the way is:

Under your config directory in your home assistant installation create the following structure:
custom_components/device_tracker/
and download this file https://raw.githubusercontent.com/home-assistant/home-assistant/c360466817776b2c2c858e3b98a894685d73b8bc/homeassistant/components/device_tracker/google_maps.py in there.
Then in your configuration.yaml create the following entry as mentioned in the documentation.

device_tracker:

The [email protected] should be your “tracking” google account. The concept is that you create an account in google that will work as your tracking account. You share the location of the actual account you want to track to the tracking account and the component will create a gps entry of all shared location accounts under your tracking one.

I hope this makes sense and helps people setting this up before it gets into the main line. Please keep in mind that google security is quite tight so you might receive emails from google upon initialization of the component about suspicious activity, much like you will if you try to log in from an unknown location with your account.

12 Likes

Thank you so much costas It literaly took 1 minuits to setup this with your instructions :slight_smile:

It’s it working as expected as of now will use this for few days and update on the performance.

Cool, great that it worked for you!

Hi,

I tried this recently and got a ‘permission denied’ error when trying to export cookies to ‘google_maps_location_sharing.conf’. Running HA on Raspian (virtual environment).

Any ideas on resolving the permission issue?

Cheers

The cookies should be automatically exported for you upon a succesful login. Maybe you are on an older version?

Thank you for that! Your instructions are clear and easy. I made it work! Works like a charm!
What is the interval for that component? Is it live, meaning that it updates everytime google maps is updating, or what?

I noticed, that the component didnt update the location on home assistant, until I opened the location sharing link and viewed it on the actual google maps on my browser <-- I hope this sentence made sense.

Have you tried with the latest code? I’ve changed the location where the cookies are stored yesterday.

I have a small objection with the use of the .conf suffix for the cookies. I think it is going to lead people to look into the file. I would much prefer the .cookies suffix.

I’m having some trouble installing this. After share my location using an other google account and created the config and downloaded the google_maps.py in “custom_components/device_tracker/”. I get the following error:

2018-02-18 16:31:16 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform google_maps
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/components/device_tracker/__init__.py", line 165, in async_setup_platform
    disc_info)
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 327, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 250, in _wakeup
    future.result()
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 243, in result
    raise self._exception
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/device_tracker/google_maps.py", line 33, in setup_scanner
    scanner = GoogleMapsScanner(hass, config, see)
  File "/config/custom_components/device_tracker/google_maps.py", line 52, in __init__
    hass.config.path(CREDENTIALS_FILE))
  File "/config/deps/lib/python3.6/site-packages/locationsharinglib/locationsharinglib.py", line 179, in __init__
    if cookies_file and self._validate_cookie(cookies_file):
  File "/config/deps/lib/python3.6/site-packages/locationsharinglib/locationsharinglib.py", line 204, 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

Before the error I see this message: 2018-02-18 16:31:11 INFO (MainThread) [homeassistant.loader] Loaded device_tracker.google_maps from custom_components.device_tracker.google_maps

What step do I mis?

Using Homeassistant: 0.60.1

Hello

I have a SmartHome system would like to track again SmartHome system my location of the mobile phone to control various things.
Is there a possibility to get the data only with a request of course with the Abi key.
I just need the coordinates everything else I can do in large format in Json format.

https://www.googleapis.com/geolocation/v1/geolocate?key=YOUR_API_KEY

I ask a tip.

Thanks! It works, I have only 1 problem left.
I used my email address where only my wifes location is shared.
So I set up my dummy gmail and shared both mine and my wifes location with this account.

I used the new account, restarted, no error, and it still uses my old account ( i know it is mine, because I see the dummy accounts location…).
The funny part I removed the account from config totally, even deleted it and restarted it, but it seems like it saved it somewhere. How can I just make it a fresh start to force use my dummy account?

Thanks!

edit.:
Just tested, it uses my old account, and the credentials are not even in the config anymore. Deleted restarted HA and it still uses it. How?
To test: added another location share to my original account and it popped up on my HA map.
How can I totally wipe my credentials ? Where does it store? What do I have to delete?

Check the device in the knowndevice.yaml file if it is there removing it might help.

Wiped the known device yml everytime I changed something. IT just reads my old accounts devices there…

The created cookies under the config directory so it starts using your new account. As long as there are valid cookie files under the config it will not re authenticate

To be more explicit you need to remove google_maps_location_sharing.conf and reload.