I have spent hours on Google Maps integration to work but it never worked for me.
Yeah, that’s kind of what I’m seeing too.
I do recall it was not as straightforward as it should have been to get the cookie file and into HA, but once I did it pretty much worked. I did go through the process a few times since I started using HA years ago (as I did major upgrades to HA or the system I was running it on), and each time it was a chore. I think I ended up using Chrome, opened an “incognito” window (or whatever it calls it), logged into Google Maps, and then used the get_cookies.txt extension to grab the cookie file. That seemed to work best. FWIW, my cookie file is about a year old and it’s still working. (Of course, now that I say that…)
I would be more than willing to use the built in HA device tracking, but their logic around “updates” is a bit odd. Seems like I have a choice of 1 min or 15 min.
I used to use an app ages ago (egigeozone) which had lots of options, like “stealing” gps updates from other apps when they requested a location (both still got it, but it could cut down on the number of gps location requests). I believe that app, or another would cut down or suspend updates as long as the phone showed no movement (like sitting on a table).
I don’t know if LIfe360 did similar things because it was all obfuscated away, but it had pretty good battery life. Not sure I want the HA app polling every minute and 15 minutes for location data is just kinda not worth it (to me).
Does anybody here have a link to a video on setting up Google maps for tracking on HA?
I don’t have a video, but I just went through the process again. This time I used Microsoft Edge & a different cookie extension (because that’s what I’ve been using recently.) The resulting cookie file appears to work, but I won’t know if it stops working in a short while like some people have experienced until I use it for a while. I’ll try to report back in a week or so.
Here is the procedure I used:
- Install Cookie-Editor (Cookie-Editor - Microsoft Edge Addons) in Microsoft Edge.
- Manage Extensions → Cookie-Editor details.
- Check “Allow in InPrivate”.
- Open Microsoft Edge InPrivate browser window.
- Browse to
www.google.com/maps
. - Sign in.
- Open Cookie-Editor extension in sidebar.
- Click on
__Secure-1PSID
to expand it. - Click “Show Advanced”.
- Uncheck “HTTP Only”.
- Click the save button for that cookie.
- Repeat steps 9 - 11, but for
__Secure-3PSID
. - Export to Netscape (which copies the cookies into the Windows clipboard.)
- Save clipboard contents to an appropriately named file (see HA Google Maps doc page) and place in HA’s config directory (typically
/config
, but that depends on your HA install method.) - Close InPrivate browser window.
- (Re)start HA.
EDIT: Updated per suggestions below.
EDIT 2: See slightly easier procedure using a different cookie extension in this post below.
Thanks for this. I think there might be a missing step after 10 where you need to press the Save button before exporting. I found that if I exported without the save then it didn’t actually remove HTTPOnly from the export for 1PSID. It did seem to be a little bit hit and miss though whether it exported correctly even after pressing Save. For anyone who is trying this, just make sure that you look at the text of the file that you create in step 12. Find the line containing _Secure-1PSID and make sure that the start of the line is .google.com and not #HttpOnly.google.com.
Ah, thanks! Yes, it wasn’t clear how this worked. I did hit that save button a few times, but I couldn’t correlate that to anything. Now it makes sense.
Well, then I would say you should hit save for both __Secure-1PSID
and __Secure-3PSID
, because those are the cookies the locationsharinglib seems to care about.
I was able to create the Netscape cookie file. I pasted to a Word doc file what file extension do I need to save it as under /config
I’ve been thinking of a way to get around life360’s stupid new security protocols…
I think there might be a way but its like an Uber-kludge…
Essentially there is no real way to have one app read another push messages… but there is an API that allows you to transfer/foward these messages to bluetooth devices (e.g. Casio watch). So essentially the HA App would have to mask itself as a bluetooth entity and then messages would be forwarded to it. 2 big issues - A. such masking is a very non-trivial task - doable yes, but not simple. B. Of course Apple would never accept this in its App Store. so the app would only be available to iOS users who have a developer account or possibly as a beta for TestFlight (although Apple does check apps that are publicly available on TestFlight). Anyhow real long shot, but possible…
Yes, I had a problem first time and ended up repeating and removing HTTPOnly on both 1PSID and 3PSID and now it’s working.
Don’t use Word, you want a simple text file. You can use something as simple as Notepad to create it. No file extension, it’s really important to make sure that you don’t give it a file extension such as .txt, so if you do use Notepad then save it as type “All files (.)”.
Thank you Phil. I was having the cookie problem with Google Maps. I got it working again using FireFox and instructions posted elsewhere but we’ll see for how long. I wondered if Edge might work so I will give your instructions a try if the cookie crumbles again.
-Tim
Phil, thank you very much for the detailed description. Awesome job.
(caveat: I am an idiot!)
- In your description, are the two entries (1PSID and 3PSiD) saved to the same .google_maps_location… file or into separate files?
- Trying to track my wife and me, so I have three email accounts: one for each of us and the last for the HA integration. Is this correct or should there only be my wife and my accounts?
- As I’m using the Studio Code Server add-on to HA to create and edit these google location files, is the config directory the same as the configuration.yaml directory?
I truly do appreciate your efforts to support the community, even for those of us who aren’t the amish dude in Paul Hibbert’s YT videos!
Cheers!!
No problem. The Google Maps integration probably isn’t as easy to use as one would hope. Given that there is really no supported API for this either, I’m not sure there’s much that can be done about it.
Anyway, the locationsharinglib (that the integration uses) looks for both of those cookies, but it’s happy if it sees either. I’m just playing it safe saying to make sure both do not have “http_only” checked, but it has worked with just __Secure-1PSID
. I’m really just guessing here. Either way, they get saved to a single file (along with a bunch of other cookies, per Google account. See more on the number of accounts next.)
I did remark somewhere (and I have to change that), that you don’t need an extra Google account just for HA. Well, you don’t, but then you don’t get a couple pieces of data for the one account you do use (which is probably your own. The missing data is battery level and picture.) Per the official docs, I’d say it’s better to have that extra account, and set up the integration to use both. (I just tried that myself, and it is indeed better.) You’ll get two entities for yourself, but just ignore the one without the missing attributes.
Yes, the cookie file(s) go into the same folder as your configuration.yaml file.
Just updating with my own experiences from the last day. I set up the integration yesterday and it was working fine. Today I noticed that tracked devices showed “Away” when they weren’t. My HA instance restarts daily along with other containers overnight for backups, and upon restarting HA shows the log error that the token for Google is now invalid. So the token was fine last night, the “special” account was ONLY used to log on last night to grab the token, but still it became invalid by the time that HA restarted less than 12 hours later. I’ve now attempted to log back into the Google account to get a new token and it told me that there had been unusual activity on the account and I needed to verify the account. This asked for my phone number to send a text. I’d used a separate phone number that I don’t normally use, but it then told me that the phone number had been used too many times. It’s ONLY on this account and it was only used once yesterday when I set up the account. I’m now completely stuck because I can’t validate the account and so have no way to even log into it. So it looks like Google are clamping down on this kind of account activity and so this is no better than Life360
I should add, I’ve now reconfigured it to remove the “special” account entirely so that it now authenticates as my real account. That’s got me back up and running, but I’ve no idea how long it will last. The benefit to me is that I’m more likely to appear as a “normal” account than one that I create just for this purpose, so hopefully less likely to get flagged.
Interesting. FWIW, as I mentioned above, I just recreated my cookie files for both my usual account and the HA only account. The system is running fine. I’ve restarted it and it still runs fine. Again, time will tell.
Also, I did get the usual “signed into a new device” type emails and messages on my phone, but nothing more than that after clicking “yes, it was me.”
Do you have 2FA enabled?
Also, take a look at the cookie file. There is a timestamp for each cookie. They are “Unix Epoch” timestamps. What do you see for the two important cookies? For mine, the timestamp is 1739381355, which corresponds to Wed Feb 12 2025 17:29:15 GMT+0000, which means it shouldn’t expire for just over a year. Again, we’ll see…
Yes, the expiration on the cookie originally gave me hope. Like you, mine said Feb 25. But I’ve just restarted HA and already it tells me that the cookie is no longer valid. It’s very strange. My main account that I’m running with has 2FA but I’ve had no alerts (I have an Android phone) to indicate account issues etc. and there’s nothing showing if I look at my account activity online. The “other” account didn’t have 2FA set up.
Maybe it needs to have 2FA??? Both my accounts do.