Thanks for this, finally worked for me
So I’m currently using own tracks via encrypted open mqtt port in home assistant.
Both my wife and I have Android phones.
Do you think the Google tracking is better than own tracks?
What are the advantages / disadvantages?
Is this something that is still a little bit of an under the table hack / work around where Google may change something and then it will stop working again?
In my opinion, Google Location Sharing itself is far better than the others if it not broken like present.
The advantages: Is use Location from google maps, you can use it without install 3rd softwares on any android phones, and I think your personal data is more secure.( you just have to share your dummy fake account detail to tracker, not your real account).
The ways to achieve it in fact is not hard( Even right now, although I not sure about the performance).
It can track your GPS. It know ecxactly where you go.
Disadvantages: Of course, because right now the 3rd lib locationsharing is now broken, and not sure when this issue will be fixed.
Dont know how long this workaround still work, too. It is unstable.
You should use Owntrack, if it work fine.
Maybe a stupid question, but are the issues with Google Maps Location sharing already resolved? Some people (also in this thread) indicate that clearing the cookies is sufficient, but others indicate that it is totally broken…
To my own surprise it started working
I cannot remember changing anything. I am using the custom component approach as indicated above.
I find that I have to recreate the cookie every couple of weeks. Anybody working on a permanent solution?
I’m having a problem with location sharing too. I’ve been trying to debug it for a few hours tonight without success. I’ve tried the cli.py and it gives me a similar error as HA does in the log files (InvalidCredentials). Here’s the home assistant log:
2019-01-29 04:59:01 ERROR (SyncWorker_19) [locationsharinglib.Service] Could not open pickle file, either file does not exist or no read access.
2019-01-29 04:59:02 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform google_maps
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/__init__.py", line 183, in async_setup_platform
disc_info)
File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/google_maps.py", line 46, in setup_scanner
scanner = GoogleMapsScanner(hass, config, see)
File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/google_maps.py", line 65, in __init__
hass.config.path(CREDENTIALS_FILE))
File "/usr/local/lib/python3.6/site-packages/locationsharinglib/locationsharinglib.py", line 366, in __init__
cookies_file=cookies_file)
File "/usr/local/lib/python3.6/site-packages/locationsharinglib/locationsharinglib.py", line 225, in __init__
self._authenticate()
File "/usr/local/lib/python3.6/site-packages/locationsharinglib/locationsharinglib.py", line 263, in _authenticate
self._submit_password()
File "/usr/local/lib/python3.6/site-packages/locationsharinglib/locationsharinglib.py", line 306, in _submit_password
raise InvalidCredentials(body)
locationsharinglib.locationsharinglibexceptions.InvalidCredentials:
Right after that it spits out a data structure with a bunch of data in it like my email address and Google picture link and a message that says “INCORRECT_ANSWER_ENTERED”. I’m sure the credentials are correct, I verified it several times using an incognito window. I never get to the point where the cookie file was created. This account doesn’t have 2-step on it and it used to work fine with location sharing in home assistant but I’m moving my home automation to another computer and now it’s broken and I can’t get it working again.
Here’s the message from cli.py:
$ python3 cli.py --email '[email protected]' --password 'mypassword' --cookies-file .google_maps_location_sharing.cookies
Traceback (most recent call last):
File "cli.py", line 143, in <module>
main()
File "cli.py", line 137, in main
CookieGetter(args.email, args.password, args.cookies_file)
File "/home/user/t/locationsharinglib/locationsharinglib/locationsharinglib.py", line 351, in __init__
cookies_file=cookies_file)
File "/home/user/t/locationsharinglib/locationsharinglib/locationsharinglib.py", line 218, in __init__
self._authenticate()
File "/home/user/t/locationsharinglib/locationsharinglib/locationsharinglib.py", line 256, in _authenticate
self._submit_password()
File "/home/user/t/locationsharinglib/locationsharinglib/locationsharinglib.py", line 299, in _submit_password
raise InvalidCredentials(body)
locationsharinglib.locationsharinglibexceptions.InvalidCredentials:
[["gf.sicr",null,null,5,null,[null,null,"type: FIRST_AUTH_FACTOR\n",1,null,"INCORRECT_ANSWER_ENTERED",null,null,1,6,null,null,null,null,null,"MyName","[email protected]","http://urltoapicture",null,null,1,1,{"1001":[1]
,"5001":[2]
}]
]
]
$
I’m not sure how to get a cookie file now. What’s interesting is if I use one of my old cookie file, the cli.py execution returns a prompt and no error, as if it succeeded. The cookie file, however, isn’t changed (and still doesn’t work with HA). If I touch a new cookie file and execute the cli.py, it returns an error of “Ran out of input”. This is telling me that the cookie file is actually an input to the cli.py, not an output file. Where are we supposed to get the cookie file from if not cli.py?
Where is the cookie file stored? I may be having a problem unrelated to yours… Not seeing that a cookie file was ever generated on my install, though I may just be overlooking the location.
It started working for me!.
I deleted cookie file, restarted hass, also shared my location for dummy account.
Also I have added that dummy account to my android phone, and I got notification to confirm connection (after hass restart), after I confirmed, location is working.
Only thing I cannot figure out is how to make battery sensor from google device tracker. Also charging status would be awsome.
In the config folder.
It’s named .google_maps_location_sharing.cookies
so it may be hidden.
You can extract the battery level:
sensor:
- platform: template
sensors:
phone_battery:
friendly_name: 'Phone Battery'
value_template: '{{states.device_tracker.google_maps_000000000000000000000.attributes.battery_level | round}}'
unit_of_measurement: '%'
And the charging state of the battery:
- platform: template
sensors:
phone_battery_charging:
friendly_name: 'Phone Battery Charging'
value_template: '{{states.device_tracker.google_maps_000000000000000000000.attributes.battery_charging}}'
Just replace the tracker id on value template
Ths, already tried this and it works great!
Anyone knows how does gmap location effects battery life in android phone?
I know why this wasn’t working and I just got it fixed!! It turned out to be that my password was TOO STRONG!
I had a backslash in my password and I think that some of the underworkings were interpreting it as an escape character instead of part of the password. I replaced it with something more … compatible, and now the cookie file is generated the device tracker gets created and everything works! Yay!
Something strange is going on…
I added my wifes phone to the map location, and her phone shows up on the map, can even see her phone battery status, all fine there.
Then I add share my own map location with the same gmail account i shared her location …
my phone shows up as home, I can see the lat and long, but when i click the entry I can not see my own phone battery it just says false. and another thing thats different, is where as it lists her name fine under “full name” and under " id" it shows a lot of numbers. And on my phone it just lists my gmail address on both name and id…
ok, replying to my own question here but I was pondering to delete my post, but I figured the solution instead, if it may help others.
So what I did, to try and solve this, was to remove the .google_maps_location_sharing.cookies and the known_devices.yaml files. rebooted the raspberry… and volia… it worked like a charm.
Since Feb 20, my Google maps component fails upon boot. I continue to get this error in the log file:
2019-02-27 09:31:08 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform google_maps
further down in the Log file:
locationsharinglib.locationsharinglibexceptions.InvalidCredentials:
[[“gf.sicr”,null,null,5,null,[null,null,“type: FIRST_AUTH_FACTOR\n”,1,null,“INCORRECT_ANSWER_ENTERED”
I have deleted the cache file and changed my password without any success.
I am on the latest HA release. Any thoughts?
Did you ever resolve this?
Thank you.
@Diginorse, you mention the cookie file twice. Can you please specify exactly what you did?
Thanks a lot
This is because Google changed something in the way that authentication works for Maps. I reported this bug against LocationSharingLib a while ago
https://github.com/costastf/locationsharinglib/issues/58
Unfortunately, we’ll just have to wait until it gets resolved and the new locationsharinglib makes its way back into Home Assistant.
Yepp I was a little to quick with the copy/paste there, I have edited my original post now. But in short I deleted the known_devices.yaml and the .google_maps_location_sharing.cookies files. and rebooted.