Device Tracker, Best echange for Life360

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 (.)”.

1 Like

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. :wink:

-Tim

1 Like

Phil, thank you very much for the detailed description. Awesome job.

(caveat: I am an idiot!)

  1. In your description, are the two entries (1PSID and 3PSiD) saved to the same .google_maps_location… file or into separate files?
  2. 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?
  3. 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 :roll_eyes:

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.

Both the account with 2FA and the one without have the same problem with the token though. And I can’t even back back IN to the one WITHOUT 2FA now because it’s blocking my use of the phone number!

I’ve recreated the cookies file again anyway, worked fine, worked fine after another HA restart. I’ll try to restart again later to see if it’s lasting.

“FILE SHOULDN’T HAVE ANY EXTENSION” I wish official instruction was more clear about this step. This was the reason I was never able to make it work. Finally it’s working.

You could always just create another account.

Yes, that will be interesting to hear how it goes for you. I’m effectively doing the same test (with newly created cookie files. I’ve had one in constant use for almost a year without issue, but I think that one is getting close to expiring.)

I did actually create another account yesterday, that time using my regular phone number. I got locked out of it in the same way. I’m now out of phone numbers :slight_smile:

I’ve just restarted HA and the cookie is now invalid.

Out of curiosity, when you logged into Google Maps, did you check the box that said something like don’t require 2FA for this device again, or something like stay logged in, or something to that effect? I would think that has more to do with the browser, but maybe it has some effect on the cookies.

I have been messing with trying to get this to work for days…
I have no errors in the logs, but I get no entities showing up. If I change anything in the cookies or filename, I do get errors. I have 2 accounts in my configuration.yaml, ahome assistant dedicated one and my personal… for testing.

Can you see anyone from the Google Maps app (from one or both of those accounts)?

You could try enabling debug:

logger:
  logs:
    locationsharinglib: debug
    homeassistant.components.google_maps: debug

I didn’t recently, but I must have done in the past. If I log out of my Google account, remove it and then log back in then I still don’t get an MFA prompt. But if try to log in using InPrivate then I get the MFA prompt (and the “Don’t ask me again on this device” option).

I’ve been having a read around other threads online about authenticating to other Google APIs using cookies in this way and they’re littered with people reporting similar things about the tokens. Without a way to periodically refresh the token that HA is using then it’s not looking particularly positive that this will be reliable for everyone. I’m not sure what is different that allows yours to continue to function, but fingers crossed it stays that way for you!

I can see myself as sharing location when I am logged in as the home assistant account.
I was in a private window when I downloaded the cookies and closed the window before rebooting home assistant, so I assume it was logged out everywhere but the home assistant instance.
I added the debug flag to my configuration and am now seeing:

Thank you for your help!

I see the I had accidently rem’ed out the device_tracker header in that last error-log…

It is now working!

I made sure the fake account was seeing the shared locations, followed the Netscape export procedure from the above-posts, logged out of the fake account before rebooting Home Assistant, and deleted my personal google login from my configuration. Having only one login seems to be the main difference from what I was doing before.

Thanks for the help!

I’ve created an issue for the man page for Google integration with some feedback that (I think) would help get this working.

Not sure who monitors these issues, but hopefully someone can update the page soon.

@pnbruckner
Phil, thanks for your instructions.

Related: what is the correct format of the Username that should be used within the configuration.yaml?
Is this a normally formatted email address or the slugified address used when saving the cookies file name?

Thanks in advance :slight_smile: