For last 6-8 months onwards, google map location sharing has started to not updating the location randomly (at least it seems random).
I would copy the cookies and it would work for some time and then it would stop working again.
It has persisted through multiple different version of Haas. I am currently on
Home Assistant 2023.7.3
Frontend 20230705.1 - latest
I see in my logs that sometimes it throws the error
[homeassistant.components.google_maps.device_tracker] The cookie file provided does not provide a valid session. Please create another one and try again
But I cookie file was valid when I put fresh cookies and Haas was able to get location too at that time. It would just stop working randomly after some time. Not sure what could be wrong or what I can do to keep it working. It worked for more than year first time I enabled google maps but last 6-8 months it has been very unreliable and cause my location based automations to fail (including in home/out home detection)
Same here. Iāve been trying to debug it using the python lib that HA uses. It appears the cookie file is read once, at HA start time. So if you are seeing that error you probably restarted HA with an invalid cookie file. You donāt see it until you restart
Iāve also discovered you only need 3 cookies for it to work :
__Secure-1PSID
__Secure-3PSID
__Secure-1PSIDTS
Itās the last one Iāve found to be problematic. If you open a maps browser window, hit F12 to examine the cookies and refresh after about 20mins, that cookie will have changed (and the HA location tracking will then stop) I found the same when testing the python lib in a loop, after about 20mins that cookie is no longer accepted.
I spoke to the python lib dev on github who recommended creating a new google account, get your family to share location with that account and use that accounts cookie. But Iāve not got around to trying that out.
i read that cookies change value often. I am wondering if locationsharing lib (i assume thatās the one handling this) can store value of new cookies when refreshed. not sure how creating a new account will help with this ?
just curious, do you log into your dummy account from browser or use that account ? I am wondering if using google for any other purpose (outside maps) may be updating the cookies. In that case we will need to create a throwaway account fully isolated (and un-used otherwise) for it to work consistently.
can you share which github repo/developer account is used for this feature ? Maybe it will be help to have an official answer/workaround for this to work consistently.
No, not at all. That account is used only as a ārecipientā for the locations of the different people, and I never log in nor use it for any other purpose.
if it works, i would be okay updating cookies once a year. so here is what i did, i installed a browser extension called āeditthiscookieā.
I logged into common google account
Exported the cookies
Used extension editthiscookie to delete all the cookies for google.
I am hoping this will make sure that cookies do not get updated but are still valid. So far (in about 16 hours) location tracking seems to be working okay. Will update how it goes over next few days.
nice work, thanks. I did the same and noticed this time that I donāt get a __Secure-1PSIDTS (which was the problematic one) Iāve restarted my test code and Iāll know in 20mins if this fixed it.
@carefulcomputer do you happen to have an old cookies file (where it stopped working) ? If so, check for __Secure-1PSIDTS - if its there I think itās a reasonable workaround to proactively removed it when the cookies are extracted.
unfortunately I didnāt save old file. my current cookies file with __Secure-1PSIDTS is still holding fine for more than a day. BTW in my file I see that __Secure-1PSIDTS and __Secure-3PSIDTS both have exact same value.
So it sounds like the solution is to remove the problematic cookie entry?
Seems like we want to delete all cookies EXCEPT for __Secure-1PSID and __Secure-3PSID from the cookies file?
Historically I just dump the cookies and copy the file into the hass directory but the last few weeks this only works for ~1 day then it stops working.