Thankyou @pnbruckner . That’s what I thought, but, after a while you start doubting everything you are doing. I just tried again and everything seems to be working properly.
@pnbruckner I am getting this error:
ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform legacy google_maps
config.yaml
device_tracker:
- platform: google_maps
username: "[email protected]"
Any suggestions why?
I would think you’re also getting another error. Can you share all related errors?
If there aren’t any, then maybe you need to enable debug for homeassistant.components.google_maps
, restart HA, and then search the FULL LOG for any messages (including DEBUG messages) with google_maps
in them.
By default, the Google Maps integration updates every 60 seconds. If you want faster update times, then you need to specify a smaller “scan interval”. E.g.
device_tracker:
- platform: google_maps
username: USERNAME
scan_interval: 10
2024-01-23 15:55:09.636 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform legacy google_maps
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/components/device_tracker/legacy.py”, line 311, in async_setup_legacy
setup = await hass.async_add_executor_job(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.11/concurrent/futures/thread.py”, line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/src/homeassistant/homeassistant/components/google_maps/device_tracker.py”, line 57, in setup_scanner
scanner = GoogleMapsScanner(hass, config, see)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/src/homeassistant/homeassistant/components/google_maps/device_tracker.py”, line 76, in init
self.service = Service(credfile, self.username)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.11/site-packages/locationsharinglib/locationsharinglib.py”, line 98, in init
self._session = self._validate_cookie(cookies_file or ‘’)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.11/site-packages/locationsharinglib/locationsharinglib.py”, line 153, in _validate_cookie
session = self._get_authenticated_session(cookies_file)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.11/site-packages/locationsharinglib/locationsharinglib.py”, line 149, in _get_authenticated_session
raise InvalidCookieFile(message) from None
locationsharinglib.locationsharinglibexceptions.InvalidCookieFile: Could not open cookies file, either file does not exist or no read access.
2024-01-23 15:55:09.645 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform legacy google_maps
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/components/device_tracker/legacy.py”, line 311, in async_setup_legacy
setup = await hass.async_add_executor_job(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.11/concurrent/futures/thread.py”, line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/src/homeassistant/homeassistant/components/google_maps/device_tracker.py”, line 57, in setup_scanner
scanner = GoogleMapsScanner(hass, config, see)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/src/homeassistant/homeassistant/components/google_maps/device_tracker.py”, line 76, in init
self.service = Service(credfile, self.username)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.11/site-packages/locationsharinglib/locationsharinglib.py”, line 98, in init
self._session = self._validate_cookie(cookies_file or ‘’)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.11/site-packages/locationsharinglib/locationsharinglib.py”, line 153, in _validate_cookie
session = self._get_authenticated_session(cookies_file)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.11/site-packages/locationsharinglib/locationsharinglib.py”, line 149, in _get_authenticated_session
raise InvalidCookieFile(message) from None
locationsharinglib.locationsharinglibexceptions.InvalidCookieFile: Could not open cookies file, either file does not exist or no read access.
Well, there’s your answer.
You need to make sure the cookies file is named correctly and written to the correct location. See my detailed instructions several posts up
I went back through the instructions again from the beginning successfully exported my cookie file saved in the \config\ [email protected]. Open the file in File editor both statements show “True”. Here are my current logs:
Logger: homeassistant.components.device_tracker
Source: components/device_tracker/legacy.py:311
Integration: Device tracker (documentation, issues)
First occurred: 5:06:24 PM (2 occurrences)
Last logged: 5:06:24 PM
Error setting up platform legacy google_maps
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/components/device_tracker/legacy.py”, line 311, in async_setup_legacy
setup = await hass.async_add_executor_job(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.11/concurrent/futures/thread.py”, line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/src/homeassistant/homeassistant/components/google_maps/device_tracker.py”, line 57, in setup_scanner
scanner = GoogleMapsScanner(hass, config, see)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/src/homeassistant/homeassistant/components/google_maps/device_tracker.py”, line 76, in init
self.service = Service(credfile, self.username)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.11/site-packages/locationsharinglib/locationsharinglib.py”, line 98, in init
self._session = self._validate_cookie(cookies_file or ‘’)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.11/site-packages/locationsharinglib/locationsharinglib.py”, line 153, in _validate_cookie
session = self._get_authenticated_session(cookies_file)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.11/site-packages/locationsharinglib/locationsharinglib.py”, line 149, in _get_authenticated_session
raise InvalidCookieFile(message) from None
locationsharinglib.locationsharinglibexceptions.InvalidCookieFile: Could not open cookies file, either file does not exist or no read access.
Hi,
The name of the cookie file must contain underscores like this
.google_maps_location_sharing.cookies .xxxxxx_gmail_com
Thank you very much!!
Yep, as @ValMarDav points out, you missed most of step 10.
This is definitely one of the more error prone steps. In my update, there will be a file selection step that allows you to easily upload the file, even via drag & drop:
No need for complicated renaming or figuring out how to get it onto the system in the right place with the right permissions, etc. It will even verify the correctness of the file right then before continuing.
I’ve found with this integration though (or the google maps app), the GPS accuracy attribute often goes from 20 to 5 all of a sudden, and it will report that someone has left the house, because they jumped outside of the zone.
Still trying to find a solution for that. For now I just make the zone bigger, but that also means I will detect people leaving the house later (although I do see them come home earlier!)
This didn’t use to be a problem with the life360 integration. I thought it was an android problem as per previous posts as well, but I’ve seen it on iPhones happen as well.
Well first, a smaller GPS accuracy value means a more accurate location fix, not less.
The accuracy value can be thought of as the radius (in meters) of a circle around the point specified by Latitude & Longitude. The actual location of the device is anywhere inside that circle. So, smaller accuracy means smaller circle means smaller area within which the device is actually located.
If the accuracy jumps from 20 to 5, that means it more accurately located your device.
The accuracy, I assume, comes from the device’s GPS system. So, I would think that would be common to Google Maps and Life360. However, I don’t know if maybe the two apps ask for the location in different ways and/or with different parameters. Maybe Life360, in general, gets more accurate readings more often than Google Maps does. Don’t really know. (FWIW, I’ve recently started using GPSLogger, and that app has parameters you can change as to how fast/accurate it gets a GPS fix. That is what I’m basing my comments above on.)
Another thing to consider is the max_gps_accuracy
setting for the HA integration. Both Life360 & Google Maps has a setting like this. Basically, if the reported accuracy value is bigger than this maximum, (i.e., the location fix is less accurate than the limit), then the update is skipped/ignored. This is to prevent very inaccurate readings from providing undesirable results. Still even if the center jumps way out of a zone that the device is still actually inside due to an inaccurate fix, in theory at least, the GPS accuracy value should create a circle big enough to still intersect the zone’s circle, so it should still report the device in the zone (unless, of course, it now overlaps a different zone as well!) If you haven’t specifically set this option, the default (for Google Maps) is 100,000 meters, so effectively there is no limit (the circumference of the Earth being less than 25,000 meters) and all updates, no matter how inaccurate, will be used.
Lastly, and I covered this a few posts up, Google Maps by default only updates every 60 seconds, whereas Life360’s update interval was like 10 or 12 seconds (I think.) But you can configure Google Maps to query more often if you like. Although, I’m not entirely sure what the ramifications may be to querying more often, if any.
Ah that makes sense. My max_gps_accuracy is set to 200, so that’s probably why it jumps out of the home circle.
Yes I also setup google maps update to 10 seconds, CPU seems somewhat increased but I will have to check in the daytime.
I have noticed that iPhones in my experience so far actually work better. I have one Samsung galaxy tab 10.1 who keeps lagging behind other phones for 2-3 minutes. A side effect of that it seems (as the other phones don’t do this (as often) it keeps reporting it home/left home etc, I don’t think that should happen.
I have the device_tracker set to :
max_gps_accuracy: 100
scan_interval: 10
And my home zone has a radius of 50. But this happens when the tablet is far away as well. The tablet might have bad gps but then I still would not expect the integration to report it as home or away when it’s clearly not home and flip between those when it’s 10km away. I noticed when I set the accuracy to like 50 or 20 even, the other phones also start exhibiting this kind of behaviour, so I put it back up to 100.
Maybe I need to put it much higher for the tablet to behave.
The integration does not decide what zone the device might or might not be in. It only reports the location & accuracy, and the device tracker component level code decides on the state of the entity.
The way it does that is by comparing the “location circle” (as I explained, based on the lat/lon & accuracy) to all the “zone circles” (based on lat/lon & radius.) If the location circle intersects one or more zone circles, then the device’s state will be the name of the “best” zone circle (based on distance from the center of the location & zone circles, etc.) If it does not intersect any zones, then it is away (i.e., not_home
.)
So, if a device is jumping around, it’s what the device is reporting, and the Google Maps integration is only the middleman between the device and the device tracker component level code. It can’t know that the device is reporting incorrect GPS data (including accuracy.)
Have you tried adding a map card with those tracker entities and set a history period of maybe a few hours? It will show a “bread crumb” trail for each device. You can then see exactly where it is reporting the device is (even if it really isn’t in some of those locations.) It doesn’t, however, show the accuracy circles. You could also create a template entity for each tracker entity whose state is the accuracy of the associated tracker entity. Then you could also plot a graph of that to see if/when it reports very inaccurate (i.e., high value) results. (Of course, that will only show values up to the set max accuracy.)
That doesn’t make any sense. Again, with smaller maximum accuracy settings the integration with “throw out” more inaccurate updates, not the reverse.
I have a custom version of the Google Maps integration available for beta testers. You can find it here:
pnbruckner/ha-google-maps: Custom Home Assistant Google Maps Integration (github.com)
See the README.md for details about what’s new, how to use it, etc. (I still need to fill in the section with the detailed instructions of how to obtain a cookies file, but that info is already “out there”, so let me know if you need a link.)
If anyone wants to give this a try, please don’t hesitate to ask for help, and please provide feedback, good or bad. I want to get any remaining issues (none that I’m aware of right now) resolved ASAP.
Hi,
I have installed your integration. I think one step is missing during the installation. We must go to the Settings, devices and services and install the Google Map integration. Apart from a small lack in the documentation, no problem to install.
Thank you for your work.
To be honest I find that google maps is not a really good exchange for life360. The foundation is different and the integration and possibilities are very different. A service like Glympse.com is more like life360. But that would need some love from a developer before it can work.
Thanks for giving it a try. I’d really like to hear how it works for you.
Well, technically speaking, that is not an installation step. Installation is getting it into the custom_components
folder so HA knows it exists. You do that via HACS or via manually installing it.
What you are referring to is the same as any integration you configure via the UI. You “add” an integration entry and supply any required configuration data. Some integrations can only be added once, and others, like this one, can be added as many times as you like, in this case, once per Google account you want to use.
I’m not sure it’s necessary to explicitly state this in the integration specific documentation since it’s a common HA procedure.
Anyway, I’ll make a mental note of your comment and if this becomes a common problem, I can add more explicit instructions.
You’re very welcome!
That’s pretty vague. Can you expand on that?
I’ve used Life360 & Google Maps in HA for years and both have worked pretty well, at least as far as providing useful location (and other) data.
I’m very interested to hear what you base those comments on and what you think is lacking in the Google Maps integration. Thanks!