GMaps - customized google_maps component

I really like using the google_maps device tracker, mostly for the fact that I don’t need to run another app on my phone and neither does my SO. Like many, I’ve had trouble with it for the past several months due to Google changing authentication seemingly randomly. Sometimes clearing the cookie out worked, but mostly not, and creating my own cookie with the maps-cookie-getter didn’t work, either, but it did work with the latest version of locationsharinglib directly. Version 4.0.1 is not a drop in replacement for 3.0.11 that my HA was using, so I dove in and tried to figure out how to make it work.

Just to be clear, virtually none of this is my own code; it’s the stock google_maps component modified. It would be great to update the core component, but since this method depends on an external program or process to create your cookie, I don’t think it would be accepted as is.

You can more or less just change your device_tracker yaml to gmaps from google_maps. password is no longer used since you have to authenticate manually. Then create your cookie and copy it over the existing google maps cookie in your configuration directory.

I did add a new configuration variable, scan_interval, as querying google every 30 seconds started getting me blocked. Not sure why, but upping it to 60 seconds seems acceptable.

I’m trying to build the maps-cookie-getter into it’s own standalone windows exe file to make it a bit easier, but I’m pretty new at all of this. Here it is on my GitHub:

Let me know what you think or if you have problems,

Denny

4 Likes

Hi! Sorry for being a noob on this. How do I get the cookie? I really don’t get it. I have tried the commmand::
maps-cookie-getter
But I get an error:
raise UnsupportedDefaultBrowser
mapscookiegettercli.mapscookiegettercliexceptions.UnsupportedDefaultBrowser

Do I need a browser to get the cookie? I’m running a hassbian on a pi3.

Yes, you need a graphical browser to log into Google for it to grab the cookie. You can install mapscookiegetter on windows and then copy the cookie file over.

Got it working. Thanks.