Core: Error setting up platform google maps in 0.89.0

Created on 7 Mar 2019  路  37Comments  路  Source: home-assistant/core

Home Assistant release with the issue:
0.89.0

Last working Home Assistant release (if known):
0.88.2

Operating environment (Hass.io/Docker/Windows/etc.):
Virtualenv on RPi

Component/platform:
Device Tracker/Google Maps

Description of problem:
After upgrade hass from 0.88.2 to 0.89.0 platform Google Maps does not start

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

- platform: google_maps
  username: [email protected]
  password: someemailpass
  max_gps_accuracy: 100

Traceback (if applicable):

Error setting up platform google_maps

Traceback (most recent call last):
  File "/home/pi/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/__init__.py", line 184, in async_setup_platform
    disc_info)
  File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/pi/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/google_maps.py", line 46, in setup_scanner
    scanner = GoogleMapsScanner(hass, config, see)
  File "/home/pi/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/google_maps.py", line 66, in __init__
    self.service = Service(self.username, self.password, credfile)
  File "/home/pi/homeassistant/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py", line 366, in __init__
    cookies_file=cookies_file)
  File "/home/pi/homeassistant/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py", line 225, in __init__
    self._authenticate()
  File "/home/pi/homeassistant/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py", line 263, in _authenticate
    self._submit_password()
  File "/home/pi/homeassistant/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py", line 306, in _submit_password
    raise InvalidCredentials(body)
locationsharinglib.locationsharinglibexceptions.InvalidCredentials: 
[["gf.sicr",null,null,5,null,[null,null,"type: FIRST_AUTH_FACTOR\n",1,null,"INCORRECT_ANSWER_ENTERED",null,null,1,6,null,null,null,null,null,"SOME EMAIL","[email protected]","https://lh3.googleusercontent.com/xxxxxxxxx/xx/photo.jpg",null,null,1,1,{"1001":[1]
,"5001":[6,["gf.uicd","xxxxxxxxxxxxxx"]
]
}]
]
]

Additional information:

google_maps

Most helpful comment

I confirm everything works as excepted now without upgrading so it must come from Google.

All 37 comments

Same error here after upgrading to 0.89.0

Yeah I'm having the exact same issue after upgrading to 0.89.0.

aparrently the pickle is the problem lol

Could not open pickle file, either file does not exist or no read access.
Log Details (ERROR)
Thu Mar 07 2019 09:39:36 GMT-0500 (Eastern Standard Time)
Could not open pickle file, either file does not exist or no read access

Error setting up platform google_maps

Error setting up platform google_maps
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/components/device_tracker/__init__.py", line 184, in async_setup_platform
    disc_info)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/device_tracker/google_maps.py", line 46, in setup_scanner
    scanner = GoogleMapsScanner(hass, config, see)
  File "/usr/src/app/homeassistant/components/device_tracker/google_maps.py", line 66, in __init__
    self.service = Service(self.username, self.password, credfile)
  File "/usr/local/lib/python3.7/site-packages/locationsharinglib/locationsharinglib.py", line 366, in __init__
    cookies_file=cookies_file)
  File "/usr/local/lib/python3.7/site-packages/locationsharinglib/locationsharinglib.py", line 225, in __init__
    self._authenticate()
  File "/usr/local/lib/python3.7/site-packages/locationsharinglib/locationsharinglib.py", line 263, in _authenticate
    self._submit_password()
  File "/usr/local/lib/python3.7/site-packages/locationsharinglib/locationsharinglib.py", line 306, in _submit_password
    raise InvalidCredentials(body)
locationsharinglib.locationsharinglibexceptions.InvalidCredentials: 
[["gf.sicr",null,null,5,null,[null,null,"type: FIRST_AUTH_FACTOR\n",1,null,"INCORRECT_ANSWER_ENTERED",]
]
}]
]
]

@fiservedpi - I don't know what is a pickle file,
if they are files:
.google_maps_location_sharing.cookies or google_maps_location_sharing.conf
they are in the hass root dir, as always, and have not been changed since the previous update

Looks like the dependency was updated to 4.0.1 on pypi, can anyone here try that and see if it fixes the issue?

https://pypi.org/project/locationsharinglib/

looks like revert changes https://github.com/home-assistant/home-assistant/commit/c637bad1ebff1347ce85436b055e5abea5c4a83d#diff-581927e0251e69c1b216d15c8ff4208d fix the problem!

so, renamig old cookies file like as wrote: https://github.com/home-assistant/home-assistant/issues/21733#issuecomment-470847401 solving a problem

Same error here. Do you know how to fix it? Do we need to wait for the next HA release?

so it looks like the change done modified the cookie file name....did you guys get a new cookie with your user id mixed in now? Maybe that cookie needs to be created? If that is the case that PR would need to be considered a breaking change. Look at the updated docs for the component to see if that helps.

I deleted the cookie file and it's not being re-created (probably because of the InvalidCredentials error. By mistake, since I deleted the cookie file I can't recover it but that would be useless in my case because I change my Google password recently.

CC: @ToSa27 is this something you can help with? looks like a user reported reverting your PR fixed the issue for them

I tried to revert the commit and still get the error:

Error setting up platform google_maps
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/components/device_tracker/__init__.py", line 184, in async_setup_platform
    disc_info)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/device_tracker/google_maps.py", line 46, in setup_scanner
    scanner = GoogleMapsScanner(hass, config, see)
  File "/usr/src/app/homeassistant/components/device_tracker/google_maps.py", line 67, in __init__
    self.service = Service(self.username, self.password,hass.config.path(CREDENTIALS_FILE))
  File "/usr/local/lib/python3.7/site-packages/locationsharinglib/locationsharinglib.py", line 366, in __init__
    cookies_file=cookies_file)
  File "/usr/local/lib/python3.7/site-packages/locationsharinglib/locationsharinglib.py", line 225, in __init__
    self._authenticate()
  File "/usr/local/lib/python3.7/site-packages/locationsharinglib/locationsharinglib.py", line 263, in _authenticate
    self._submit_password()
  File "/usr/local/lib/python3.7/site-packages/locationsharinglib/locationsharinglib.py", line 306, in _submit_password
    raise InvalidCredentials(body)
locationsharinglib.locationsharinglibexceptions.InvalidCredentials: 
[["gf.sicr",null,null,5,null,[null,null,"type: FIRST_AUTH_FACTOR\n",1,null,"INCORRECT_ANSWER_ENTERED",null,null,1,6,null,null,null,null,null,"XXXX","[email protected]","https://lh3.googleusercontent.com/-oQNHvsb1IEo/AAAAAAAAAAI/AAAAAAAAAAA/ACHi3rflc8ravd4hIDRm-Pe5YPVYVBXsyA/mo/photo.jpg",null,null,1,1,{"1001":[1]
,"5001":[6,["gf.uicd","AAWk9lRN0MMY0yU6DeE61INlraukVT7VEdF0J68bDHsoiA-JokDXVibaJNzqn6ALNVIOXXXXXXXXXXXXXXug9OFbl5ydPLcW7hxtY5n66yvkdzD9Ab-zBgr5JTJDFEJW5ysed4nJ26WQLeBHPhUs8gDQnEGhx3MhcWU7fuH5VEoZpmlQJx_GI"]
]
}]
]
]

I am not sure the error is the same... feel free to tell me and I will open a new ticket if needed.

Same issue here on 0.89.0

I'm now seeing this as well.

I had mentioned that when I submitted the merge request. New pickle files are generated for each user account. As long as the credentials are maintained in the HA config (probably in secrets.yaml), that should happen automatically and not require any user interaction or config change. That's why it's not a breaking change. If that nasty upstream issue is not fixed though, more users would run into failures creating the pickle files which appears to be the case now.
I did not update to 0.89.0 yet. Will do this evening and check if there is anything else broken.

Is there a.way to manually recreate the pickle file until we see the upstream issue fixed and merged? @ToSa27

Same issue too, but my Google Hangouts also died completely. It was also complaining about authentication so I deleted the integration and couldn't re-add it. Had to do a botchy workaround recreating the cookie string from a webbrowser and recreate an entry in the entity database.

Google maps, however I havent been able to find a fix for.

@kylerw There was a manual workaround discussed as part of the upstream issue but I just tried that without success. Seems like Google actually changed their authentication again (which would explain why @callifo mentioned that Hangouts failed as well).

If you want to try the manual workaround - should work on any machine with python 3 and pip 3 installed and you should be able to copy the pickle file over to the HA config directory afterwards (but again - doesn't work for me right now but results in the same error reported above):

pip3 install 'locationsharinglib==3.0.11' --force-reinstall
python3
>>> from locationsharinglib import Service
>>> service = Service("[email protected]", "password", cookies_file=".my_new_pickle_file")

I had to manually install pytz as well as it wasn't picked up as a dependency properly (pip3 install pytz
).

If you still have the old pickle file, you should be able to rename it (append a dot and then the slug of your google username), it should pick it up and work just fine.

With the update of the locationsharinglib to 4.0+, it appears that the author removed the entire credentials handling and now the library expects a working cookies file as input, probably because google is messing around with the authentication method too often. If that's the case, some major rework on the HA component would be required to still make it work seamlessly (getting the cookie retrieval coded into the HA component)...

That doesnt work for me,

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/locationsharinglib/locationsharinglib.py", line 366, in __init__
    cookies_file=cookies_file)
  File "/usr/local/lib/python3.7/site-packages/locationsharinglib/locationsharinglib.py", line 225, in __init__
    self._authenticate()
  File "/usr/local/lib/python3.7/site-packages/locationsharinglib/locationsharinglib.py", line 263, in _authenticate
    self._submit_password()
  File "/usr/local/lib/python3.7/site-packages/locationsharinglib/locationsharinglib.py", line 306, in _submit_password
    raise InvalidCredentials(body)
locationsharinglib.locationsharinglibexceptions.InvalidCredentials:
[["gf.sicr",null,null,5,null,[null,null,"type: FIRST_AUTH_FACTOR\n",1,null,"INCORRECT_ANSWER_ENTERED",null,null,1,6,null,null,null,null,null,"xxx Homeassistant","[email protected]","https://lh3.googleusercontent.com/xxx/mo/photo.jpg",null,null,1,1,{"1001":[1]
,"5001":[6,["gf.uicd","xxx"]

Which is the same error that is repeated in my Home Assistant log files.

@ToSa27 - if username for google maps location sharing is [email protected]
and old cookies file name is .google_maps_location_sharing.cookies
what should be the name of the new file ??

.google_maps_location_sharing.cookies.someuser_gmail_com ??

EDIT:
yes, with renamed file like this:
_.google_maps_location_sharing.cookies.someuser_gmail_com_
locationsharing works

@reaper7 it's using the slugging function that's used across HA in a lot of places. I didn't look at the code but based on what I see in my config folder, the slug should be someuser_gmail_com, hence the filename should be .google_maps_location_sharing.cookies.someuser_gmail_com
If you have e.g. another . in the username like firstname.[email protected], then the slug would be firstname_lastname_gmail_com

@ToSa27 Correct, also on the docker image it works now after renaming the file.

It also looks like when you rename the original file too something else it does create a dummy file.
I forgot to replace the extra dot the first time and after the restart I suddenly had two files ;)

The . with the right cookie and the _ with the faulty one.

This appears to be fixed in 0.89.1. I had deleted the cookie after it stopped working, and it has now recreated it properly and started working again.

Can confirm - update from 0.89.0 to 0.89.1 fixed it. All works fine now with google maps location sharing.

@callifo @infestdead Happy to hear it's fixed for you in 0.89.1 - but I'm struggling to understand why. There is no visible change between 0.89.0 and 0.89.1 in that specific component. Maybe just a coincidence with Google changing something again on their end. That would explain why the steps to manually create the pickle file shared a few posts earlier are now working again on my end as well (same machine, same parameters, same version of the lib, ...)
Would be interesting to hear from others that are still on 0.89.0 if the issue suddenly disappeared again (after e.g. a reatsrt to re-trigger the pickle-file creation)...

@ToSa27 - I also checked it, no visible change in this component...it seems that something on the google side has changed.

@ToSa27 I checked it by restarting HA 0.89.0 first, but still have the error about the pickle file. Didn't delete pickle file however before restarting.

After updating to 0.89.1, the error is gone, again, without deleting the pickle file beforehand.
I checked the pickle file and can see that a file has been created with .username_gmail_com at the end. The old file without .username_gmail.com is also still there, but seems to be an old file.

I confirm everything works as excepted now without upgrading so it must come from Google.

Still have problem after update to 0.89.1,

docker on rpi 3b+

finaly, after update to 0.89.1 and renaming file to:
.google_maps_location_sharing.cookies.myaccount_gmail_com
issue disapppeared

yeah mine just magically fixed itself

I think we should close this issue.

@grzech666 I suggest you open a new issue describing in detail your error. It seems to be a different one than the one most people had here.

Agree to close - but the issue actually is a good reminder that this component is a ticking timebomb - with v4 of the locationsharinglib the creation of the pickle file seems not to be included anymore but expected as an input... and if Google decided to change the login procedure, it could break from one day to the next as it's not an officially supported API.

I agree with that. Another issue should be opened about it probably.

come to the dark side...

seriously though. my shit's been working flawlessly ever since the 0.7X days. just did a pretty decent overhaul of the core modules while working with another member who wanted to get this working under docker with compose.

i've got considerable debugging built in with URL tracking and screenshots as well as raw request output for quick troubleshooting. it's designed specifically to work with device notification 2FA, and considering that the use case for this is pushing the cal/location/whatever from multiple other accounts to this account, not having 2FA enabled is just stupid. any other 2FA method would just cause either the component or HA to timeout/error.

hello all, i am also having this issue on hass.io on the pi, i have tried deleting cookie file etc and i am still getting this issue, it recreates the file and gives these errors in the log:

2019-05-01 08:11:24 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform google_maps
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/device_tracker/__init__.py", line 177, in async_setup_platform
    disc_info)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/google_maps/device_tracker.py", line 39, in setup_scanner
    scanner = GoogleMapsScanner(hass, config, see)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/google_maps/device_tracker.py", line 60, in __init__
    self._update_info()
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/google_maps/device_tracker.py", line 72, in _update_info
    for person in self.service.get_all_people():
  File "/usr/local/lib/python3.7/site-packages/locationsharinglib/locationsharinglib.py", line 439, in get_all_people
    people = self.get_shared_people() + [self.get_authenticated_person()]
  File "/usr/local/lib/python3.7/site-packages/locationsharinglib/locationsharinglib.py", line 400, in get_shared_people
    for info in output[0]:
TypeError: 'NoneType' object is not iterable
2019-05-01 09:11:14 ERROR (MainThread) [homeassistant.components.updater] Got unexpected response: None

i am happy to try this gmapslocsharing thats been mentioned in comments, but i am a new with this so i have now idea how to do it, but i am willing to give it a go if someone is willing to tell me step by step. thanks all.

I'm having the same issue here @rookster1984

@rookster1984 @corneels

Remember to remove your .google cookie file before you start this

(DO NOT DO THIS UNLESS YOU UNDERSTAND WHAT IT IS)
try delete your known device from your google page.
go to https://myaccount.google.com/u/2/security
under 'Less secure app access', turn on.

Can confirm that tyjtyj's fix works (for me, at least). Previously when the nonetype iterable error was occurring, deleting the cookie file and restarting twice was the fix. This time I deleted the cookie file and then just deleted the known device from the Google account (I did NOT turn on 'less secure app access' as the integration doesn't need to use this and I don't want to expose my account unnecessarily). Restarted twice and boom. Fixed.

Was this page helpful?
0 / 5 - 0 ratings