My final update unless something changes, but as of October 15 (coming up on 2 months since I created the cookie file in a different browser I never use), my home assistant is STILL logged in and getting location information from google.
So at least for me, it appears that simply using a browser you never use (in my case, edge) to export the cookies allows the cookies to stay valid for a long time since the browser never is opened and goes to a page where google will update the cookie values.
I literally did nothing beyond opening edge, logging into google maps, and exporting my cookies. Closed edge, and I haven’t opened it since.
I just started having issues with this as well. Great timing right after Life360 goes down.
I figured the cookie just expired like it has a few times before. So I opened up Firefox (browser I never use), navigated to maps.google.com, signed in to the shared-to account, pulled the cookie, replaced the cookie and rebooted. I got “new sign in” notifications for that account when HA rebooted but the entities still aren’t updating.
Any tips?
EDIT: Got it. Guess I just had to keep trying until I got a cookie that took.
EDIT 2: Spoke too soon. Rebooted to get Life360 fixed and Google Maps broke again. Uggh
I believe there is a possibility of fixing the problem of expiring cookies. This fix is based on observation that when using browser, it never logs out which indicates that before old cookies have expired, by that time server has already sent updated cookies so a client can watch for new cookies and keep updating self. I am not very good with python so if anyone want to contribute, that will be awesome. Here are two high level changes -
Homeassistant provides the callback to locationsharinglib and stores the new cookies as returned by callback and uses that cookie to call locationsharing lib that point onwards
The Alexa Media Player integration used to constantly deal with having to re-authenticate to update the cookie. They’ve since been able to get it to continuously update and I can’t remember the last time I had to re-authenticate that one. Plus they moved it to GUI.
With Life360 giving us issues again, it would be a great time for perfecting the Google Maps integration. And with a simpler authentication/cookie flow and no need for YAML it could be very popular. Unfortunately I don’t have the skillset to do it.
I do plan to make some improvements to the Google Maps integration, specifically adding UI based config flow, converting it from a “legacy” tracker (that uses known_devices.yaml) to the newer entity-based style, add device info, and possibly making the cookie file name a bit more flexible.
Unfortunately, I don’t know much about how cookie files, and websites in general, work to help with improving the authentication/authorization part. I don’t have the skillset to do that.
This procedure worked for me. I didn’t use HA companion app on other devices but shared their location to the google account. Then on the user account on HA I used their device to track. This gave me the location of my family devices on the map in HA. Hope it works fine.
From experience, what is key is to immediately close the browser after capturing the cookie file. If you don’t, the cookie you got quickly gets invalidated by new requests done in the background by the page.
FYI, as I know I’ve mentioned before, I’m working on a significantly improved Google Maps integration. Before I submit anything officially, I’m testing out the changes in a “custom component” repository. I will probably have something ready later today for anyone who’d like to try it out – even though not all the documentation is in place yet, and it might still have issues – and provide feedback. I’ll provide the repo URL when it’s ready. I’m willing to “hand hold” anyone who’d like to try it.
FYI, it still has the existing “legacy” tracker implementation, so after switching to it, you should see no difference, except for a warning that says the legacy implementation is deprecated. At that point, you can “add” the integration the usual way via the Integrations page in the UI. It will create new entities (that shouldn’t “collide” with the existing, legacy ones), so you can see how it works side-by-side with the original.
Here is what I have implemented so far:
Add UI-based config flow, including reconfiguration via the CONFIGURE button.
Enable or disable creation of the tracker entity associated with the registered account. Note that this entity is lacking some info (full name, battery level, etc.) Trackers are still created for all people shared with this account regardless of this setting.
Can use existing cookies file if found (which eases upgrading), but also includes a file upload feature that makes adding/updating cookies much easier. (I.e., no confusing file renaming and figuring out how to get the file onto the system and in the right place.)
Read and display cookie expiration date in config flows.
Create a repair issue at startup if cookies will expire in the next four weeks.
Check cookie expiration during normal operation (not just at startup.)
Initiate reconfiguration flow when cookies expire (either at startup or during normal operation.)
Save & restore state during HA restart or config entry reload (which also happens when new cookies are loaded.)
Enhance error checking & handling. (Hopefully) no more uncaught exceptions in the log!
As implied above, I still need to work on the documentation. I also plan to test out the cookie file creation procedure on Chrome, Edge & Firefox, and include details instructions for each, possibly even including them in the UI config flow.
Note, unfortunately, there doesn’t seem to be a way to do the authorization directly in HA, so the annoying step of grabbing cookies is still required. However, I’m trying to make that as painless as possible.
Ok, I think the custom integration is good enough for limited usage by those that are willing to provide feedback and can deal with possible issues until I can resolve them. Also, I’ve only done extensive testing with HA 2024.1.5 (and to some extent the dev branch.) I don’t know if there are any issues with older versions, so ymmv.
Also note that for some reason, HACS does not report version tags but reports commit hashes instead. This may be due to the fact that this repo only has beta releases so far. FWIW, 4b21442 is equivalent to 1.0.0b3, which is the latest available release at this point.
Just checking in, as having fought with the google maps integration since Life360 bailed.
This post, mr. bruckner, was the sought-after piece of the puzzle! clarification of the process was all I needed to get it all working.
At least since yesterday afternoon, EDT, USA.
Google Chrome is my browser of choice, and the pertinent info about my setup
Core 2024.3.1
Supervisor 2024.03.0
Operating System 12.1
Frontend 20240307.0