Core: google_maps device_tracker: TypeError: 'NoneType' object is not iterable

Created on 13 Oct 2018  ·  130Comments  ·  Source: home-assistant/core

Running latest version - 0.80.0

Configuration:

  - platform: google_maps
    username: !secret google_maps_username
    password: !secret google_maps_password
    max_gps_accuracy: 200

In 0.79.3 .google_maps_location_sharing.cookies was created but nothing appeared in logs and no new device_tracker in HA.
After upgrading to 0.80.0 I get the following error:

home-assistant   | 2018-10-13 18:57:35 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform google_maps
home-assistant   | Traceback (most recent call last):
home-assistant   |   File "/usr/src/app/homeassistant/components/device_tracker/__init__.py", line 184, in async_setup_platform
home-assistant   |     disc_info)
home-assistant   |   File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
home-assistant   |     result = self.fn(*self.args, **self.kwargs)
home-assistant   |   File "/usr/src/app/homeassistant/components/device_tracker/google_maps.py", line 46, in setup_scanner
home-assistant   |     scanner = GoogleMapsScanner(hass, config, see)
home-assistant   |   File "/usr/src/app/homeassistant/components/device_tracker/google_maps.py", line 66, in __init__
home-assistant   |     self._update_info()
home-assistant   |   File "/usr/src/app/homeassistant/components/device_tracker/google_maps.py", line 78, in _update_info
home-assistant   |     for person in self.service.get_all_people():
home-assistant   |   File "/usr/local/lib/python3.6/site-packages/locationsharinglib/locationsharinglib.py", line 459, in get_all_people
home-assistant   |     people = self.get_shared_people() + [self.get_authenticated_person()]
home-assistant   |   File "/usr/local/lib/python3.6/site-packages/locationsharinglib/locationsharinglib.py", line 421, in get_shared_people
home-assistant   |     for info in output[0]:
home-assistant   | TypeError: 'NoneType' object is not iterable

Nothing appears in Device Activity page.

Running in docker over Ubuntu 16.04

google_maps problem in dependency

Most helpful comment

Until the code is updated, you can temporarily work around the problem by using lufton's code to create the cookie file separately (I did it on a separate linux box and then uploaded the cookie file to hassos).

git clone https://github.com/lufton/locationsharinglib.git
cd locationsharinglib/
mkvirtualenv -p `which python3` locationsharinglib
pip install -r requirements.txt 
python cli.py --email '<your email>' --password '<your password>' --cookies-file 
.google_maps_location_sharing.cookies

All 130 comments

How did you setup the component? Did you make sure to create a separate account and share your locations to that one? Did a file known_devices.yaml get created and do your see the device_tracker entities in there?

Hi @dshokouhi
Component setup published in the post (or you mean something else?)
I did create a fresh new google account and shared my location from my personal account to the newly created one.
no new entities under known_devices.yaml and no google device_tracker anywhere.

BTW
After that didn't work I logged in to the new google account using the HA system (this time the system did appear in the device activity page), but still, same error in logs and no new devices.

Are you able to see your devices if you use the library directly? If you don't see the devices create an issue in that repo, if you do see your devices comment back here so they can know next steps.

https://github.com/costastf/locationsharinglib

You are right, the error comes from locationsharinglib (version 3.0.6)
Test:

service = Service(username, password, 'google_maps_location_sharing.conf')
for person in service.get_all_people():
    print(person)

Output:
Traceback (most recent call last):

  File "test.py", line 6, in <module>
    for person in service.get_all_people():
  File "/home/sagi/venv/temp/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py", line 459, in get_all_people
    people = self.get_shared_people() + [self.get_authenticated_person()]
  File "/home/sagi/venv/temp/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py", line 420, in get_shared_people
    for info in output[0]:
TypeError: 'NoneType' object is not iterable

I've opened a new issue in the relevant repository: https://github.com/costastf/locationsharinglib/issues/42

Are you able to see your devices if you use the library directly? If you don't see the devices create an issue in that repo, if you do see your devices comment back here so they can know next steps.

https://github.com/costastf/locationsharinglib

How would one go about using the directory directly?

@WedHumpDay click on the link and go to the docs

@dshokouhi If you're referring to https://locationsharinglib.readthedocs.io/en/latest/installation.html
I've already gone through this process: ( pip install locationsharinglib ) with no luck.. Problem is, I'm on Hass.io build 79.3 and each time I restart HA, Hass.io reverts back to the a different version. Been at this for days and it just will not login to Google. https://myaccount.google.com/device-activity never receives a request.

device_tracker:
  - platform: google_maps
    username: !secret google-user
    password: !secret google-pass
    max_gps_accuracy: 100
    new_device_defaults:
      track_new_devices: true

known_devices is created automatically.
Cookie is created.
config/components/device_tracker/google_maps.py

Log Details (ERROR)
Sun Oct 14 2018 18:52:54 GMT-0400 (Eastern Daylight Time)

Error setting up platform google_maps
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/__init__.py", line 183, in async_setup_platform
    disc_info)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/google_maps.py", line 44, in setup_scanner
    scanner = GoogleMapsScanner(hass, config, see)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/google_maps.py", line 63, in __init__
    hass.config.path(CREDENTIALS_FILE))
  File "/config/deps/lib/python3.6/site-packages/locationsharinglib/locationsharinglib.py", line 370, in __init__
    cookies_file=cookies_file)
  File "/config/deps/lib/python3.6/site-packages/locationsharinglib/locationsharinglib.py", line 194, in __init__
    if cookies_file and self._validate_cookie(cookies_file):
  File "/config/deps/lib/python3.6/site-packages/locationsharinglib/locationsharinglib.py", line 221, in _validate_cookie
    raise InvalidCookies(message)
locationsharinglib.locationsharinglibexceptions.InvalidCookies: The cookies provided do not provide a valid session.Please authenticate normally and save a valid session again

Can confirm same error
TypeError: 'NoneType' object is not iterable

Also tried latest hass Dev version that includes google_map.py version 3.0.6 but still same.

i'm working on rewriting locationsharinglib at the moment.

right now i got it working with 2FA device notification:
image

gonna do some cleanup and optimization on my code and then implant/replace locationsharinglib.

might need some help from the HA devs as i'm not terribly familiar with upstream data flow, but i'm pretty sure i can figure it out...

@shr00mie Hopefully progress is moving along?

@WedHumpDay how bout them fuckin' apples?
image

fucking lol
image

oh...i probably have lat and lon reversed. oops.

there we go...

image

ok...couple things:

  1. my solution is currently using selenium + chrome webdriver which also requires a chrome install. how much of an issue could this present or can we just add a script to google_maps documentation page so users can just install chrome manually if they need to?
  2. i suppose this could be rewritten yet again back to straight requests, but i really like some of the functionality offered via selenium for control and debugging.
  3. i basically threw locationsharinglib out the window and wrote my own module consisting of cookie and query modules under a parent. went to town on google_maps as well a bit.

not sure what to do next. could throw it up under a repo so you guys could check it out i suppose?

@shr00mie without a hassio addon to go along with it, nobody in hassio will be able to use this unfortunately. The USPS component required selenium but it did not work for all users. Any reason why you decided to abandon the original repo? Locataionsharinglib was recently created and it worked well for the most part. This issue in particular is also being looked at by the owner of that repo. Why not combine forces for a better product?

because owners can be possessive and i don't like going through committee to get to the best solution in the shortest amount of time...the only way i can see selenium not working is again based on poor implementation specifically as it pertains to the webdriver (for which the solution is the chromedriver_binary pip package). the only variable is the local chrome install. other than that, and assuming your paths aren't totally borked, shouldn't be an issue.

to clarify: if it was a couple lines of code. sure. fix it. this was not a couple lines of code.

out of curiosity, could Chrome headless be installed in the docker container for this to work in docker?

@wcomartin ...you sir, are a genius. since i'm running HA as a service under a standard ubuntu server install, my thinking wasn't even in containerland. implementing this with any of the containerized options would be exponentially easier as the chrome requirement could be incorporated into the build requirements. take the requirement out of the users hands and call it a day. just include the browser with the default container image for hass and crack open a beer.

ok...so who wants to help me figure out why it's not updating regularly? :smiley:

alright. fixed updating. it's pretty much ready to plug in at this point. no one's hit me up to test, so shit or get off the pot. hit me up and i'll toss you a repo invite.

you guys have the attention span of a damn goldfish...

hereyago.

@shr00mie I would say we are just busy. Was traveling for business, but back home this coming week.
I'd be willing to to give this a go around.

To confirm, will this work on Hass.io?
Its a custom VM instance install running Ubuntu with Hass.io.

Also, would be great if an addon was developed for Hass.io users.
https://developers.home-assistant.io/docs/en/hassio_addon_tutorial.html

I would attempt but at this time I cannot commit to a development project as I'm quite busy at the office till end of the year.

I had downgraded HA to v0.78.0 for another issue and location tracking was working fine. After updating back to v0.80.3, it stopped working, again.

@WedHumpDay right now, i would probably consider this a proof of concept. the approach uses selenium instead of requests for cookie generation. it does require the host to have a working install of google chrome as well. implementation and testing of proposed changes would be easier for advanced users under docker, and manageable for less skilled users under a normal linux server install as you can just ssh in and git clone to the .homeassistant config folder. if people like the approach and we get some of the bugs ironed out as well as add some more error catching, this could be very easily rolled into a container image without any further action from users. this is my first time contributing to a project, and i have no idea how to package, so i'd definitely need some help with that if/when this is deemed viable.

@Sarabveer that seems to be the theme. my approach works with 0.80.3 and uses selenium to interact with the css elements via chrome. it was also designed and tested with device notification 2FA, but could very easily be modified by using configuration input for other login types as long as they are not of the captcha variety. i could see it working with authenticator as well by sensing the 2FA prompt and presenting an input popup/notification via HA frontend for input.

It looks like the original library used by the component has been fixed : https://github.com/costastf/locationsharinglib/issues/42#issuecomment-431195508

I believe we should only get the fix imported into HassIO

It looks like the original library used by the component has been fixed : costastf/locationsharinglib#42 (comment)

I believe we should only get the fix imported into HassIO

The library is still not fixed..

well...the fix has been given to the library's owner, waiting for him to commit the changes into the code

@acarlo79 which fix are you referring?
Not to confuse everybody, but there are couple of requested fixes in the pipeline. More importantly, needs to resolve for all HA configurations, including Hass.io, Virtualization, Hassbian, etc.

google_maps component uses locationsharinglib to get the GPS position, with the proposed fix (which I tested also with HassIO) the component will work again correctly (still missing the 2FA).
So once the fix (to authenticate the library using the google api) will be committed, we have to wait for a new HassIO/Hasbian/Virt release to contain the updated library.

does it make sense?

@acarlo79 locationsharinglib doesn't use google api, but go on...

Anyone confirmed Hass.io 81.0 resolved this?

Anyone confirmed Hass.io 81.0 resolved this?

This issue relays in locationsharinglib library and the issue is still open, so it can't be fixed in HA yet.

For reference, there is a PR: https://github.com/costastf/locationsharinglib/pull/43. When that one is tested, approved, merged, there is a new version tagged and the requirement is updated in HA it should work. So probably the next release.

Hope it wil be fixed.. Can't get it working sinse my first install on 0.78.0 and locashionsharinglib v3.0.0
Have reported twice to the lib author, but still no working desicion..

ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform google_maps
Traceback (most recent call last):
  File "/srv/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 "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/google_maps.py", line 46, in setup_scanner
    scanner = GoogleMapsScanner(hass, config, see)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/google_maps.py", line 66, in __init__
    self._update_info()
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/google_maps.py", line 78, in _update_info
    for person in self.service.get_all_people():
  File "/srv/homeassistant/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py", line 459, in get_all_people
    people = self.get_shared_people() + [self.get_authenticated_person()]
  File "/srv/homeassistant/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py", line 420, in get_shared_people
    for info in output[0]:
TypeError: 'NoneType' object is not iterable

you can lead a horse to water...

image

image

tried with 0.81.2, no go under Hass.io. Appears it hasnt been merged as of yet

Does it make sense to update the components wiki page to say that this is currently broken?

Where does this leave the resolution for Hass.io users?

.82.0 release notes doesn't indicate this was resolved. Will retest sometime this week as I'm traveling.

bummer...

image

image

Hate to be a bare of bad news, still broken for Hass.io !! Still cannot get the device to show up under dummy Google account. And, yes, I have to phones sharing to the dummy account.

Details (ERROR)
Tue Nov 13 2018 21:24:07 GMT-0500 (Eastern Standard Time)

Error setting up platform google_maps
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/__init__.py", line 184, in async_setup_platform
    disc_info)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/google_maps.py", line 46, in setup_scanner
    scanner = GoogleMapsScanner(hass, config, see)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/google_maps.py", line 65, in __init__
    hass.config.path(CREDENTIALS_FILE))
  File "/usr/local/lib/python3.6/site-packages/locationsharinglib/locationsharinglib.py", line 386, in __init__
    cookies_file=cookies_file)
  File "/usr/local/lib/python3.6/site-packages/locationsharinglib/locationsharinglib.py", line 210, in __init__
    if cookies_file and self._validate_cookie(cookies_file):
  File "/usr/local/lib/python3.6/site-packages/locationsharinglib/locationsharinglib.py", line 237, in _validate_cookie
    raise InvalidCookies(message)
locationsharinglib.locationsharinglibexceptions.InvalidCookies: The cookies provided do not provide a valid session.Please authenticate normally and save a valid session again

Its not listed as fixed yet. Only workaround now is the custom lib shr00mie fix? or wait for this pull request to be included?
https://github.com/costastf/locationsharinglib/pull/43

Its not listed as fixed yet. Only workaround now is the custom lib shr00mie fix? or wait for this pull request to be included?
costastf/locationsharinglib#43

personally, i consider gps related libraries to be vital to presence detection and automation. and said libraries should be well supported and updated as regularly as necessary to fix any upstream changes. feels like the current lib is maintained by only one person, which is a pretty damn big point of failure when so many people depend on its continued and reliable functionality.

i don't know or think that my resolution is the best for the time being or going forward. that said, i'm a solutions kinda guy. instead of waiting around for what at this point i consider an unacceptable period of time, put something else in place and move on. just because it's been done a certain way, doesn't mean it's what should be used going forward if it's so easy to break and takes so damn long to fix. we're not mapping the human genome here. let's not get married to what exists if it's not working or isn't getting fixed.

In regards to @shr00mie's comment, if location is a critical component and its going to be unreliable like this, perhaps it should be considered adding the functionality of the library directly in the home assistant repository instead, that way the whole team has access and can fix any issues that arise instead of relying on a single developer of a project to fix/merge a solution

perhaps @shr00mie's solution should be integrated into the home assistant repository and maybe make it use PhantomJS so there is no requirement on installing chrome, and everything can be installed from pip

thoughts?

In agreement. Having been a QA Build Engineer for a software developing company back in the day. The current process seems to be failing. This is directly in relation to a single threaded developer providing updates. As @wcomartin mention, ideally, placing the function directly within HA would be an overall better solution.

From a business perspective; now that HA is charging a monthly premium, development should be re-evaluated to be more structured on how updates are provided in a timely manner.

In regards to @shr00mie's comment, if location is a critical component and its going to be unreliable like this, perhaps it should be considered adding the functionality of the library directly in the home assistant repository instead, that way the whole team has access and can fix any issues that arise instead of relying on a single developer of a project to fix/merge a solution

perhaps @shr00mie's solution should be integrated into the home assistant repository and maybe make it use PhantomJS so there is no requirement on installing chrome, and everything can be installed from pip

thoughts?

i'd veto the PhantomJS path as HA is python, and keeping things consistent would i think be preferable instead of having people jump around languages/configs. thought process with my approach was that if we're trying to access google assets, while it could be achieved with other approaches, maybe a chrome browser would provide the highest degree of compatibility/inter-connectivity/wordsthatendwithity given the task. hence chrome+selenium.

i'm a big fan of the higher level abstraction and functionality offered by selenium compared to requests for the login/cookie component. it felt like the original library was using a lot of RE to figure out what was on the page which could be achieved with considerably less lines via selenium. it's possible that this approach/conclusion is simply due to my ignorance of requests capabilities, but it felt like controlling and interacting with, for all intents and purposes, a full browser, provided not only more control at low-high levels, but might be a stronger long term solution. not gonna lie, the screenshot capability came in stupid handy during development as well as ongoing debugging.

and i have a hard time believing that there aren't other libraries/components that couldn't be streamlined or might benefit from being able to leverage a full fledged browser being made available to HA.

another benefit of rolling this into HA is that the browser could be rolled into the container build image in the Hass.io variant while simply providing a chrome install script for the more hands on standalone install. logic being that if you're going the standalone route, you probably know how to install chrome on your linux server...

anyway. i'm just spitballing here. i've never put together a package or know what checks needs doing, but i fucking love HA and whatever i can do to help/contribute...

:eggplant:

@shr00mie Selenium+PhantomJS was just an example of something easily installed via a package manager, perhaps there is something in pip that could be used. but my main point was something that was integrated more closely with HA so that external packages didn't have to be installed especially chrome unless it can be installed in that fashion,

but I'm not opposed to chrome as long as its pre-installed in the docker container which is what I use.

@wcomartin i honestly think that inclusion of chrome within docker would be the most ideal and foolproof approach. again, the thinking being that if you're doing a standalone install, you can probably be trusted to figure out how to install chrome on your own to make this work. literally a couple lines of code.

that said, anyone else tried this in standalone install (ideally on ubuntu as i haven't tested any other distros)? i know it works for me in my environment, but if we could get some other feedback, that would be nice. especially as it pertains to various login methods (this was designed for device notification auth as that seems to be the best use case for headless). i haven't built any other ones out, but was thinking that login method/2fa can be included in config.yaml to then be passed to the lib which would alter its function based that setting. could probably get it to do google auth popup via the HA UI...somehow...

Until the code is updated, you can temporarily work around the problem by using lufton's code to create the cookie file separately (I did it on a separate linux box and then uploaded the cookie file to hassos).

git clone https://github.com/lufton/locationsharinglib.git
cd locationsharinglib/
mkvirtualenv -p `which python3` locationsharinglib
pip install -r requirements.txt 
python cli.py --email '<your email>' --password '<your password>' --cookies-file 
.google_maps_location_sharing.cookies

@sherbang Thanks that worked just fine!

where did you add the cookie file to in hassos

in your "/config" folder should work. it did for me!

thanks

@sherbang This worked perfectly.!
Now, what I have done, I moved away from Hass.io to a custom VM server with Ubuntu, witih HA virtual environment. I'm extremely pleased with this direction.

While I enjoyed the Hass.io, I've always preferred to handle configurations under my control. IMHO - Hass.io seems to have more issues and at times, late with supporting certain features. Again. This is my personal opinion.

To note. This still not fixed in Hass.io .83.1. Just saying.. The work around also does not work in Hass.io.

@WedHumpDay The work around works fine for me in Hassio, I'm running it on Ubuntu instead of HassOS not sure if that matters.

@Gluwc I was running Hassio on Ubunti 18.04.1 on a VM instance. Wasnt able to get the work around to take. Regardless, Im pleased with my new setup.

Until the code is updated, you can temporarily work around the problem by using lufton's code to create the cookie file separately (I did it on a separate linux box and then uploaded the cookie file to hassos).

git clone https://github.com/lufton/locationsharinglib.git
cd locationsharinglib/
mkvirtualenv -p `which python3` locationsharinglib
pip install -r requirements.txt 
python cli.py --email '<your email>' --password '<your password>' --cookies-file 
.google_maps_location_sharing.cookies

Thanks, working for me on hassios 83.3.
Needed to get mkvirtualenv working on my ubuntu box, simple and only took 2min, followed pre-req's here: https://stackoverflow.com/questions/13855463/bash-mkvirtualenv-command-not-found

Update 0.84 has:
"Update locationsharinglib to 3.0.9 (@pc-coholic - #19045) (device_tracker docs)"

Lets hope everything is ok now 👍

Update 0.84 has:
"Update locationsharinglib to 3.0.9 (@pc-coholic - #19045) (device_tracker docs)"

Lets hope everything is ok now

Just FYI: This PR (as well as all my other HA-PRs relating to locationsharinglib) were only addressing issues, where the location of the account owner was not populated. The whole "NoneType is not iterable"-stuff never was an issue for me, so I never looked into this...

Until the code is updated, you can temporarily work around the problem by using lufton's code to create the cookie file separately (I did it on a separate linux box and then uploaded the cookie file to hassos).

git clone https://github.com/lufton/locationsharinglib.git
cd locationsharinglib/
mkvirtualenv -p `which python3` locationsharinglib
pip install -r requirements.txt 
python cli.py --email '<your email>' --password '<your password>' --cookies-file 
.google_maps_location_sharing.cookies

Thanks, working for me on hassios 83.3.
Needed to get mkvirtualenv working on my ubuntu box, simple and only took 2min, followed pre-req's here: https://stackoverflow.com/questions/13855463/bash-mkvirtualenv-command-not-found

This just worked for me after struggling for quite awhile.
Add lufton's file into a custom components directory on HASS.IO and move the cookie you create into /conf share

Until the code is updated, you can temporarily work around the problem by using lufton's code to create the cookie file separately (I did it on a separate linux box and then uploaded the cookie file to hassos).

git clone https://github.com/lufton/locationsharinglib.git
cd locationsharinglib/
mkvirtualenv -p `which python3` locationsharinglib
pip install -r requirements.txt 
python cli.py --email '<your email>' --password '<your password>' --cookies-file 
.google_maps_location_sharing.cookies

Thanks, working for me on hassios 83.3.
Needed to get mkvirtualenv working on my ubuntu box, simple and only took 2min, followed pre-req's here: https://stackoverflow.com/questions/13855463/bash-mkvirtualenv-command-not-found

This just worked for me after struggling for quite awhile.
Add lufton's file into a custom components directory on HASS.IO and move the cookie you create into /conf share

Hey there, could you please elaborate on what exactly you did for us with low coding IQ? :)
What file exactly did you get? just throw it in /custom_components/?
What does your configuration look like?
And do i get the .cookies file created by the original component and throw it in /share/?
Thanks in advance :+1:

Anyone else experience no updates starting 84.3 ? Had to roll back to 83.3 in order for the updates to show.

Is this working in 83.3 ?

Is this working in 83.3 ?

Yes. Working on 83.3. Scroll up and and you can sees its working under Hass & Hass.io.

Until the code is updated, you can temporarily work around the problem by using lufton's code to create the cookie file separately (I did it on a separate linux box and then uploaded the cookie file to hassos).

git clone https://github.com/lufton/locationsharinglib.git
cd locationsharinglib/
mkvirtualenv -p `which python3` locationsharinglib
pip install -r requirements.txt 
python cli.py --email '<your email>' --password '<your password>' --cookies-file 
.google_maps_location_sharing.cookies

Thanks, working for me on hassios 83.3.
Needed to get mkvirtualenv working on my ubuntu box, simple and only took 2min, followed pre-req's here: https://stackoverflow.com/questions/13855463/bash-mkvirtualenv-command-not-found

I'm struggling here. I created a ~/locationsharinglib/.bash_profile with the solution's lines in it, but I continue to get "command not found". Am I going about this wrong?

I am struggling getting mkvirtualenv working on Turnkey Linux. I keep getting the no such file or directory.

git clone https://github.com/lufton/locationsharinglib.git
cd locationsharinglib/
mkvirtualenv -p `which python3` locationsharinglib
pip install -r requirements.txt 
python cli.py --email '<your email>' --password '<your password>' --cookies-file 
.google_maps_location_sharing.cookies

This worked for me in version Home Assistant 84.6. In arch linux, I had to replace mkvirtualenv by virtualenvand add ./bin to $PATH.

Tried the solution by @sherbang but get the following:

Traceback (most recent call last):
File "cli.py", line 143, in
main()
File "cli.py", line 137, in main
CookieGetter(args.email, args.password, args.cookies_file)
File "/home/pi/locationsharinglib/locationsharinglib/locationsharinglib.py", line 349, in __init__
super(CookieGetter, self).__init__(email,
TypeError: super() argument 1 must be type, not classobj

i have the same error message

TypeError: super() argument 1 must be type, not classobj
did you find a solution to get the cookie ?

still going strong using my solution...

image

image

cough --> image

yes !
it's working
image

@froggy974 which solution are you using?

btw, love that you're french/in france and your username is froggy. tips hat

The workaround described by @sherbang worked for me

Ps:yes, I was not so inspired for the username ;-) to

git clone https://github.com/lufton/locationsharinglib.git
cd locationsharinglib/
mkvirtualenv -p `which python3` locationsharinglib
pip install -r requirements.txt 
python cli.py --email '<your email>' --password '<your password>' --cookies-file 
.google_maps_location_sharing.cookies

This worked for me in version Home Assistant 84.6. In arch linux, I had to replace mkvirtualenv by virtualenvand add ./bin to $PATH.

i'm sorry but i not know very well linux....
(homeassistant) homeassistant@homeassistant:/usr/local/bin $ virtualenv -p `which python3` locationsharinglib Already using interpreter /srv/homeassistant/bin/python3 Using base prefix '/usr' Traceback (most recent call last): File "/srv/homeassistant/bin/virtualenv", line 11, in <module> sys.exit(main()) File "/srv/homeassistant/lib/python3.5/site-packages/virtualenv.py", line 768, in main symlink=options.symlink, File "/srv/homeassistant/lib/python3.5/site-packages/virtualenv.py", line 1013, in create_environment install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages=site_packages, clear=clear, symlink=symlink) File "/srv/homeassistant/lib/python3.5/site-packages/virtualenv.py", line 1214, in install_python mkdir(lib_dir) File "/srv/homeassistant/lib/python3.5/site-packages/virtualenv.py", line 382, in mkdir os.makedirs(at_path) File "/usr/lib/python3.5/os.py", line 231, in makedirs makedirs(head, mode, exist_ok) File "/usr/lib/python3.5/os.py", line 231, in makedirs makedirs(head, mode, exist_ok) File "/usr/lib/python3.5/os.py", line 241, in makedirs mkdir(name, mode) PermissionError: [Errno 13] Permission denied: '/usr/local/bin/locationsharinglib'

can i help me?

It works! Raspbian 9.6 and Home Assistant 0.84 on a Virtual Environment in a Raspberry Pi 3

Steps are just a bit different than those kindly described by @sherbang in https://github.com/home-assistant/home-assistant/issues/17410#issuecomment-440357856

#from /home/pi

#clone lufton's fork
git clone https://github.com/lufton/locationsharinglib.git

#stop HA
sudo systemctl stop [email protected]


#activate virtual environment
sudo -u homeassistant -H -s
source /srv/homeassistant/bin/activate

#generate cookie file
(homeassistant) homeassistant@raspberrypi:~/.homeassistant $ python /home/pi/locationsharinglib/cli.py --email '<your email>' --password '<your password>' --cookies-file .google_maps_location_sharing.cookies

#make sure known_devices.yaml does not exist or remove it so that HA will create it from scratch. you can always edit it later to match your needs so keep a copy if needed (fixed)

#restart HA (fixed)
sudo systemctl restart [email protected]

#check https://myaccount.google.com/device-activity and there it is: new Linux session

Please, mind I have not installed lufton's fork, but just made use of the fork to generate the cookies.

thanks @vg8020 that was enough to get the cookies generated and get it working for me!

It works! Raspbian 9.6 and Home Assistant 0.84 on a Virtual Environment in a Raspberry Pi 3

Steps are just a bit different than those kindly described by @sherbang in #17410 (comment)

from /home/pi

clone lufton's fork

git clone https://github.com/lufton/locationsharinglib.git

stop HA

sudo systemctl stop [email protected]

activate virtual environment

sudo -u homeassistant -H -s
source /srv/homeassistant/bin/activate

generate cookie file

(homeassistant) homeassistant@raspberrypi:~/.homeassistant $ python /home/pi/locationsharinglib/cli.py --email '<your email>' --password '<your password>' --cookies-file .google_maps_location_sharing.cookies

make sure known_devices.yaml does not exist or remove it so that HA will create it from scratch

restart HA

sudo systemctl stop [email protected]

check https://myaccount.google.com/device-activity and there it is: new Linux session

Please, mind I have not installed lufton's fork, but just made use of the fork to generate the cookies.

This worked for me, I was getting a cookies file but it didn't work.
You dont need to delete known_devices.yaml - I had stuff I wanted to keep in there!
Your #restart HA command "stops" HA
Now I need to try to link this intelligently to open my garage when I am coming home in MY car, not someone elses, and not walking.

@spattinson It's edited now. Thank you for your remarks.

Followed @vg8020's instructions. Had to amend the destination of the cookies file to /home/homeassistant/.homeassistant (running hassbian).

With that said, I'm not getting any google maps devices in my homeassistant instance. Was I supposed to remove username and password from configuration.yaml? I have no errors in my logs either.

For me, running 0.85 under Raspberry 3 and hass.io google is dead:

2019-01-11 17:46:12 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform google_maps
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/__init__.py", line 183, in async_setup_platform
    disc_info)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/google_maps.py", line 46, in setup_scanner
    scanner = GoogleMapsScanner(hass, config, see)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/google_maps.py", line 66, in __init__
    self._update_info()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/google_maps.py", line 78, in _update_info
    for person in self.service.get_all_people():
  File "/usr/local/lib/python3.6/site-packages/locationsharinglib/locationsharinglib.py", line 465, in get_all_people
    people = self.get_shared_people() + [self.get_authenticated_person()]
  File "/usr/local/lib/python3.6/site-packages/locationsharinglib/locationsharinglib.py", line 426, in get_shared_people
    for info in output[0]:
TypeError: 'NoneType' object is not iterable

Is there any workaround for hass.io users? Strange fact - everything was fine for me with 0.84.6. Now after updating to 0.85 I got the error for the first time.

@hudecitydave check out the thread here: https://github.com/costastf/locationsharinglib/issues/42#issuecomment-439731010 and, in particular, Lufton's hack (https://github.com/costastf/locationsharinglib/issues/42#issuecomment-439731010). I was having the same issue and his hack resolved it for me.

@tehstevo Thanks, but that did not the trick for me somehow...

I still get this:

019-01-13 11:39:46 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform google_maps
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/__init__.py", line 183, in async_setup_platform
    disc_info)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/device_tracker/google_maps.py", line 46, in setup_scanner
    scanner = GoogleMapsScanner(hass, config, see)
  File "/config/custom_components/device_tracker/google_maps.py", line 65, in __init__
    self._update_info()
  File "/config/custom_components/device_tracker/google_maps.py", line 77, in _update_info
    for person in self.service.get_all_people():
  File "/config/custom_components/device_tracker/locationsharinglib.py", line 453, in get_all_people
    people = self.get_shared_people()
  File "/config/custom_components/device_tracker/locationsharinglib.py", line 414, in get_shared_people
    for info in output[0]:
TypeError: 'NoneType' object is not iterable

I played around with the google cookies...

For me the custom component generates a file called:
google_maps_location_sharing.cookies

My original component named it

.google_maps_location_sharing.cookies

Oh, what a mess...

The . in front means it's a hidden file. Delete the cookies and restart hass w the hack in place. That's what did it for me

I'm not clear on the areas of ownership here, but I believe this is directly related. The above workarounds are not working for me from several OS/python venvs. All giving me the same error as below.

[daphne@cbox locationsharinglib]$ python3 cli.py --email "[email protected]" --password PASSWORD --cookies-file .google_maps_location_sharing.cookies Open the Google App, and tap 'Yes' on the prompt to sign in ... Traceback (most recent call last): File "cli.py", line 143, in <module> main() File "cli.py", line 137, in main CookieGetter(args.email, args.password, args.cookies_file) File "/home/daphne/locationsharinglib/locationsharinglib/locationsharinglib.py", line 351, in __init__ cookies_file=cookies_file) File "/home/daphne/locationsharinglib/locationsharinglib/locationsharinglib.py", line 218, in __init__ self._authenticate() File "/home/daphne/locationsharinglib/locationsharinglib/locationsharinglib.py", line 256, in _authenticate self._submit_password() File "/home/daphne/locationsharinglib/locationsharinglib/locationsharinglib.py", line 303, in _submit_password self._handle_prompt(body) File "/home/daphne/locationsharinglib/locationsharinglib/locationsharinglib.py", line 330, in _handle_prompt response.raise_for_status() File "/usr/lib/python3.7/site-packages/requests/models.py", line 939, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://accounts.google.com/_/signin/challenge?TL

I see if i'm right the issue (https://github.com/costastf/locationsharinglib/issues/42) seems to be fixed. But the tag of locationsharinglib has not been updated. So i cannot push a new commit (update) to home assistant git to use the new code. I have created a new issue (https://github.com/costastf/locationsharinglib/issues/55) the create a new tag. When the tag is created, i will send the new version to the home assistant git.

Update on this, i have created a pull request to use the new version 3.0.11 (https://github.com/home-assistant/home-assistant/pull/20322)

Still facing this issue on 0.86.3 (HassIO)

2019-01-28 21:52:09 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform google_maps
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/__init__.py", line 183, in async_setup_platform
    disc_info)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/google_maps.py", line 46, in setup_scanner
    scanner = GoogleMapsScanner(hass, config, see)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/google_maps.py", line 66, in __init__
    self._update_info()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/google_maps.py", line 78, in _update_info
    for person in self.service.get_all_people():
  File "/usr/local/lib/python3.6/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.6/site-packages/locationsharinglib/locationsharinglib.py", line 400, in get_shared_people
    for info in output[0]:
TypeError: 'NoneType' object is not iterable

0.87 seems to reintroduce the error. I’m getting the same as the above

EDIT: fixed it by deleting the google maps cookie file and restarting twice

0.88.b0 still no success for me and non of the above workarounds work. :'(

original 0.88.b0 or @sherbang or @spattinson :

Traceback (most recent call last):
  File "locationsharinglib/cli.py", line 143, in <module>
    main()
  File "locationsharinglib/cli.py", line 137, in main
    CookieGetter(args.email, args.password, args.cookies_file)
  File "/home/homeassistant/ha-venv/temp/locationsharinglib/locationsharinglib/locationsharinglib.py", line 351, in __init__
    cookies_file=cookies_file)
  File "/home/homeassistant/ha-venv/temp/locationsharinglib/locationsharinglib/locationsharinglib.py", line 218, in __init__
    self._authenticate()
  File "/home/homeassistant/ha-venv/temp/locationsharinglib/locationsharinglib/locationsharinglib.py", line 256, in _authenticate
    self._submit_password()
  File "/home/homeassistant/ha-venv/temp/locationsharinglib/locationsharinglib/locationsharinglib.py", line 299, 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,"Luca Leone","[email protected]","https://lh3.googleusercontent.com/-1uMiaziHLbg/AAAAAAAAAAI/AAAAAAAAAAA/ACHi3rfWh-OkZ4fnSYwGqqND3imTE8lRQA/mo/photo.jpg",null,null,1,1,{"1001":[1]
,"5001":[6,["gf.uicd","AAWk9lRUVN6hkKtjlaDqI6d7HNXh58-nWK8QicXvHQc3M_exY9-8T1TolSj6HZGKOXwY8hzgiahVjsCF5NANFGcAewL9fTKz-Jlqd8sudTfjmpna4L1B8wSOWwuYjC9-Y-x5yXbfek1Ns531W3cjuMXYOaiWjDSYCqRDB94gT9N4SIDqCzqv_2Q"]
]
}]
]
]

Using a previously save cookie :
TypeError: 'NoneType' object is not iterable

Any hint ?

@lleone71 do you have multifactor auth enabled for your google account? I'm not sure it'll work with the locationsharing library. I created a new account and shared my location with it for this specific purpose.

@lleone71 do you have multifactor auth enabled for your google account? I'm not sure it'll work with the locationsharing library. I created a new account and shared my location with it for this specific purpose.

I created an ad-hoc account.
I tried without 2FA, with 2FA and with 2FA but creating an application specific password.

I think I couldl wipe everything and start from scratch: a plain vanilla HA setup with only google maps enabled. Just to try...

L.

@lleone71 Personally, I had an issue where locationsharinglib was not upgrading correctly via pip. Once I manually deleted the package files and reinstalled it, it began working.

@lleone71 do you have multifactor auth enabled for your google account? I'm not sure it'll work with the locationsharing library. I created a new account and shared my location with it for this specific purpose.

I created an ad-hoc account.
I tried without 2FA, with 2FA and with 2FA but creating an application specific password.

I think I couldl wipe everything and start from scratch: a plain vanilla HA setup with only google maps enabled. Just to try...

L.

for what it's worth, my fork is designed specifically to work with 2FA via device authentication and has been flawless since 0.81.

designed and tested for ubuntu server standalone install variant, so any other config would require some input from wanting parties.

for what it's worth, my fork is designed specifically to work with 2FA via device authentication and has been flawless since 0.81.

designed and tested for ubuntu server standalone install variant, so any other config would require some input from wanting parties.

I'm running a headless Centos 7 (gui not installed).
Install of your fork could be:

chrome:
`(
echo "[google-chrome]"
echo "name=google-chrome"
echo "baseurl=http://dl.google.com/linux/chrome/rpm/stable/$basearch"
echo "enabled=1"
echo "gpgcheck=1"
echo "gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub"
) > /etc/yum.repos.d/google-chrome.repo

yum -y install google-chrome-stable
`
home assistant:
git clone https://github.com/shr00mie/gmapslocsharing.git

?

Thanks,
L.

@lleone71 thanks! added CentOS script to my readme. updated the dependencies while i was at it.

have you tried it? does it work for you?

@shr00mie , sorry for the late reply.
I tried it but it doesn't work: nothing written into the log file (debug level), no errors/outputs displayed, nothing at all.

I managed to get something by manually grabbing the cookies SID, HSID, SSID, from a chrome session and these lines:

bash:

curl -s 'https://www.google.com/maps/preview/locationsharing/read?authuser=3&pb=' -H 'cookie: HSID=xxx SID=yyy SSID=zzz' > ./tmp1

python

import requests
url= "https://www.google.com/maps/preview/locationsharing/read?authuser=3&pb="
r1 = requests.get(url, cookies={'HSID':'xxx;','SSID':'yyy','SID':'zzz'})
print(r1.content)

but I'm not a python coder so I stopped any further attempt.

After 15 days, the HSID/SSID/SID I stole from the chrome gmap session still work.
May be putting them in the yalm file instead of username/password?

Luca.

PS:
authuser=3 because I have a google multiuser environment.
I think that for most people this should be authuser=0 or could be totally omitted.

Another release, another relapse...

Broken again with update to 0.92 from 0.91.4. Unfortunately this time deleting the cookie file and restarting twice does not fix the issue:

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

I note other users also encountering this issue again.
Hello darkness my old friend...

Same problem here.

@shr00mie , sorry for the late reply.
I tried it but it doesn't work: nothing written into the log file (debug level), no errors/outputs displayed, nothing at all.

I managed to get something by manually grabbing the cookies SID, HSID, SSID, from a chrome session and these lines:

bash:

curl -s 'https://www.google.com/maps/preview/locationsharing/read?authuser=3&pb=' -H 'cookie: HSID=xxx SID=yyy SSID=zzz' > ./tmp1

python

import requests
url= "https://www.google.com/maps/preview/locationsharing/read?authuser=3&pb="
r1 = requests.get(url, cookies={'HSID':'xxx;','SSID':'yyy','SID':'zzz'})
print(r1.content)

but I'm not a python coder so I stopped any further attempt.

After 15 days, the HSID/SSID/SID I stole from the chrome gmap session still work.
May be putting them in the yalm file instead of username/password?

Luca.

PS:
authuser=3 because I have a google multiuser environment.
I think that for most people this should be authuser=0 or could be totally omitted.

@lleone71
hey man. sorry. just saw this.
could you do me a favor and try replacing
authuser=3
with
authuser=<account.location.is.shared.with>
and let me know if you're getting the expected output?

after digging around a bit, it looks like authuser=X can be either the order from 0 -> whatever which represents the accounts you're logging into google with on your session, or can be replaced with the specific account you're looking to target. If that's the case, i would just need to tweak a bit of code to get that resolved so we're not guessing numbers anymore.

give it a go with your test case and let me know if that works. i could implement and push in like 30 minutes after you confirm.

Hello darkness my old friend...

@aegjoyce

i got your darkside right here, brah.

@shr00mie , sorry for the late reply.
I tried it but it doesn't work: nothing written into the log file (debug level), no errors/outputs displayed, nothing at all.
I managed to get something by manually grabbing the cookies SID, HSID, SSID, from a chrome session and these lines:

bash:

curl -s 'https://www.google.com/maps/preview/locationsharing/read?authuser=3&pb=' -H 'cookie: HSID=xxx SID=yyy SSID=zzz' > ./tmp1

python

import requests
url= "https://www.google.com/maps/preview/locationsharing/read?authuser=3&pb="
r1 = requests.get(url, cookies={'HSID':'xxx;','SSID':'yyy','SID':'zzz'})
print(r1.content)
but I'm not a python coder so I stopped any further attempt.
After 15 days, the HSID/SSID/SID I stole from the chrome gmap session still work.
May be putting them in the yalm file instead of username/password?
Luca.
PS:
authuser=3 because I have a google multiuser environment.
I think that for most people this should be authuser=0 or could be totally omitted.

@lleone71
hey man. sorry. just saw this.
could you do me a favor and try replacing
authuser=3
with
authuser=<account.location.is.shared.with>
and let me know if you're getting the expected output?

after digging around a bit, it looks like authuser=X can be either the order from 0 -> whatever which represents the accounts you're logging into google with on your session, or can be replaced with the specific account you're looking to target. If that's the case, i would just need to tweak a bit of code to get that resolved so we're not guessing numbers anymore.

give it a go with your test case and let me know if that works. i could implement and push in like 30 minutes after you confirm.

Hi @shr00mie,
I tried several combinations and it seems that as long as HSID, SID, SSID are correct, you can get the shared locations no matter what authuser is or if it's omitted.

So all the following give the correct result:

  1. curl -s 'https://www.google.com/maps/preview/locationsharing/read?authuser=3&pb=' -H 'cookie: HSID= SID= SSID=

  2. curl -s 'https://www.google.com/maps/preview/locationsharing/read?authuser=&pb=' -H 'cookie: HSID= SID= SSID=

  3. curl -s 'https://www.google.com/maps/preview/locationsharing/read?authuser=5&pb=' -H 'cookie: HSID= SID= SSID=

  4. curl -s 'https://www.google.com/maps/preview/locationsharing/read?pb=' -H 'cookie: HSID= SID= SSID=

  5. curl -s 'https://www.google.com/maps/preview/locationsharing/read?authuser=&pb=' -H 'cookie: HSID= SID= SSID=

  6. curl -s 'https://www.google.com/maps/preview/locationsharing/read?authuser=&pb=' -H 'cookie: HSID= SID= SSID=

When one or more of HSID/SID/SSID is wrong than you get a void reply.

Hope this helps,
Luca.

@lleone71 you'd need to grab the latest from my repo and make sure you have debug: true under the google_maps device_tracker set. also wanted to confirm that you have 2FA enabled via device authentication for the account you're trying to log in with.

messing around a bit more, it looks like authuser just pertains to the accounts logged in to google on your session, so i might just drop that entirely.

if/when you get some time, i'd say move the existing cookie file elsewhere for the test, enable debug under the google_maps device tracker config, and make sure 2FA is enabled via device auth and try again and let me know what's what.

@lleone71 you'd need to grab the latest from my repo and make sure you have debug: true under the google_maps device_tracker set. also wanted to confirm that you have 2FA enabled via device authentication for the account you're trying to log in with.

messing around a bit more, it looks like authuser just pertains to the accounts logged in to google on your session, so i might just drop that entirely.

if/when you get some time, i'd say move the existing cookie file elsewhere for the test, enable debug under the google_maps device tracker config, and make sure 2FA is enabled via device auth and try again and let me know what's what.

I had to move gmapslocsharing from .homeassistant/devs to lib/python3.6/site-packages.
Anyway :

 File "/home/homeassistant/ha-venv/ha-0.92.1/lib64/python3.6/site-packages/gmapslocsharing/core/location.py", line 1, in <module>
    from cachetools import TTLCache, cached
ModuleNotFoundError: No module named 'cachetools'

Luca.

@lleone71 you'd need to grab the latest from my repo and make sure you have debug: true under the google_maps device_tracker set. also wanted to confirm that you have 2FA enabled via device authentication for the account you're trying to log in with.
messing around a bit more, it looks like authuser just pertains to the accounts logged in to google on your session, so i might just drop that entirely.
if/when you get some time, i'd say move the existing cookie file elsewhere for the test, enable debug under the google_maps device tracker config, and make sure 2FA is enabled via device auth and try again and let me know what's what.

I had to move gmapslocsharing from .homeassistant/devs to lib/python3.6/site-packages.
Anyway :

File "/home/homeassistant/ha-venv/ha-0.92.1/lib64/python3.6/site-packages/gmapslocsharing/core/location.py", line 1, in
from cachetools import TTLCache, cached
ModuleNotFoundError: No module named 'cachetools'

Luca.

it's like you read my mind. i ripped cachetools out of my dev build while pondering its utility before you replied. if that's causing issues for you in your venv, then it's just more confirmation that based on my latest update, it's not necessary. go ahead and delete:

  • line 1 with the cachetools import
  • this bit below the imports:
STATE_CACHING_SECONDS = 30
STATE_CACHE = TTLCache(maxsize=1, ttl=STATE_CACHING_SECONDS)
  • and the decorator above the update function.

then give it another go and let me know where you're at then.

@shr00mie, I had to remove the following lines from location.py :

1. from cachetools import TTLCache, cached

13. STATE_CACHE = TTLCache(maxsize=1, ttl=STATE_CACHING_SECONDS)

230. @cached(STATE_CACHE)

and I had to install chrome from the beta channel ( yum install google-chrome-beta ).

Anyway, this is the first attempt :

Mon Apr 29 2019 16:46:05 GMT+0200 : You are using a custom integration for google_maps which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
Mon Apr 29 2019 16:46:10 GMT+0200 : Cookie file does not exist.
Mon Apr 29 2019 16:46:10 GMT+0200 : Cookie not found or invalid. Generating.
Mon Apr 29 2019 16:46:45 GMT+0200 : Browser Login Failed - Message: 
.
Mon Apr 29 2019 16:46:45 GMT+0200 : Cookie check or generation failed.

Then I generated an application specific password and :

Mon Apr 29 2019 16:52:31 GMT+0200 : You are using a custom integration for google_maps which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
Mon Apr 29 2019 16:52:37 GMT+0200 : Cookie file does not exist.
Mon Apr 29 2019 16:52:37 GMT+0200 : Cookie not found or invalid. Generating.
Mon Apr 29 2019 16:53:04 GMT+0200 : Browser Login Failed - Message: 
.
Mon Apr 29 2019 16:53:04 GMT+0200 : Cookie check or generation failed.

Is it possibile to create a version of google_maps_device_tracker where we could specify hsid/sid/ssid instead of username and password?

Luca.

@lleone71
i pushed all relevant updates to the repo. so instead of mickey mousing it, go ahead and pull from the repo.

you're also going to want to stay on google-chrome-stable because i'm syncing the chromedriver version to the stable release version, and if the chromedriver and browser are out of sync, it won't work.

check the repo readme and set debug: true in the HA config for the component. should give a decent amount of debug output in the form of data dumps, screenshots, and urls.

@shr00mie ,
I pulled the updates.
Using 2FA it doesn't work: I receive the sms with the code from google but there is no way to input this code. I think that if I linked a phone with a popup as authentication method it should work.

Disabling 2FA it works as expected.

Luca.

@lleone71
That's because the lib is specifically designed to work with 2FA via device auth, not sms, exactly because it's the only method which does not require interaction with the device/server session.
:heart:
Change your 2FA method.
Also, don't use SMS for 2FA. If you don't know why, Google sms 2fa crypto exchange

fwiw, google_maps_device_tracker continued to work for me after upgrading to 0.92.2.

Still not working for me.

Robert Fisher

On Sun, 5 May 2019, 6:27 AM Chris Helming, notifications@github.com wrote:

fwiw, google_maps_device_tracker continued to work for me after upgrading
to 0.92.2.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/home-assistant/home-assistant/issues/17410#issuecomment-489352419,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AL5OPYJDKX33FPSOKELDY6TPTXIR7ANCNFSM4F3K5S7Q
.

Still not working for me on 0.92.2

2019-05-07 22:42:42 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 357, in _async_add_entity
    raise HomeAssistantError(msg)
homeassistant.exceptions.HomeAssistantError: Entity id already exists: calendar.contacts
2019-05-07 22:42:45 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

Broken for me too.

How can we change this status from closed to open

It's closed because it's a library problem, not an HA problem.

So for someone like me who can follow good instructions, what should I do to get it working?
Or is that like flogging a dead horse.

So for someone like me who can follow good instructions, what should I do to get it working?
Or is that like flogging a dead horse.

@robfish1956 be my guest.

I now get this........(The script ran without any errors)

Wed May 08 2019 11:19:06 GMT+1200 (New Zealand Standard Time)
Your configuration contains extra keys that the platform does not support.
Please remove [mytz], [debug]. (See /home/homeassistant/.homeassistant/configuration.yaml, line 186)

The line (added to the already existing platform below device_tracker:
is
mytz: Pacific/Auckland

Thought you said you were good with instructions...

he he. I thought I was. Can you please tell me where I went wrong?
There was already this in configuration.yaml.........

device_tracker:
  - platform: google_maps
    username: ******@gmail.com
    password: ************
so I simply edited it to..............
device_tracker:
  - platform: google_maps
    country: US
    username: ******@gmail.com
    password: ************
    mytz: Pacific/Auckland

The error says....
Your configuration contains extra keys that the platform does not support.
Please remove [country], [mytz], [debug]

the existing platform does not support the keys. my variant does. if you're getting that error, that indicates that you did not copy over the required dependencies folder properly or at all. i updated the scripts if you're running HA straight on linux. the main idea is to make sure the custom_components contents exist within the HA config directory as well as the gmapslocsharing folder under the deps tree as per the structure in the linked repo.

you might also be my first non-US user (although i don't know who the f is using this), so assuming you get all the dependencies working, you might still have some URL issues, so i would recommend setting debug to true under the google_maps component so if there are any URL related complications, those can be thrown into the debug folder so you can send those over for me to implement for kiwiland.

Yes I am running in a python virtual env.
I simply ran the script and edited the platform

Robert Fisher

On Wed, 8 May 2019, 12:53 PM Alex, notifications@github.com wrote:

the existing platform does not support the keys. my variant does. if
you're getting that error, that indicates that you did not copy over the
required dependencies folder properly or at all. i updated the scripts if
you're running HA straight on linux. the main idea is to make sure the
custom_components contents exist within the HA config directory as well as
the gmapslocsharing folder under the deps tree as per the structure in the
linked repo.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/home-assistant/home-assistant/issues/17410#issuecomment-490306197,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AL5OPYOSJKWOVZDVS2HMUODPUIQBTANCNFSM4F3K5S7Q
.

humm. yeah...that's an interesting one. google chrome is a dependency, would apt even work as intended inside a venv? not really a pip thing, so i'm wondering if that would just escape and install globally. and if that's the case, probably wouldn't be able to access it from within the venv. regardless, if it was a chrome related error, i would expect that to be happening after all components were successfully initialized, which it should do, regardless of venv. i'd expect to see login failure messages during cookie generation. if you're getting config key errors, that sounds more like the custom_components and deps dir are not where they need to be.

Looks like the files/folders are not where they should be (should I expect the script to put them there?)

robert@fishhass:/home/homeassistant/.homeassistant/custom_components/device_tracker$ ls -la
total 164
drwxr-xr-x 2 homeassistant homeassistant   4096 Mar 28 16:18 .
drwxr-xr-x 3 homeassistant homeassistant   4096 Mar 28 16:18 ..
-rw-r--r-- 1 homeassistant homeassistant 156294 Mar 28 16:18 edgeos.py
robert@fishhass:/home/homeassistant/.homeassistant/deps$ ls -la
total 8
drwxr-xr-x  2 homeassistant homeassistant 4096 Jun  4  2018 .
drwxr-xr-x 10 homeassistant homeassistant 4096 May  8 13:48 ..
robert@fishhass:/home/homeassistant/.homeassistant/deps$ 

...did you make a homeassistant group along with the user? is robert a member of said group? does the homeassistant group have recursive write permissions to the .homeassistant folder?

feel free to remedy any/all of those and try again.

We are getting there. But still have (different) errors.

robert@fishhass:/home/homeassistant/.homeassistant/custom_components/google_maps$ ls -la
total 28
drwxr-xr-x 3 homeassistant homeassistant 4096 May  8 14:36 .
drwxr-xr-x 4 homeassistant homeassistant 4096 May  8 14:30 ..
-rw-r--r-- 1 homeassistant homeassistant 4422 May  8 14:30 device_tracker.py
-rw-r--r-- 1 homeassistant homeassistant   48 May  8 14:30 __init__.py
-rw-r--r-- 1 homeassistant homeassistant  341 May  8 14:30 manifest.json
drwxr-xr-x 2 homeassistant homeassistant 4096 May  8 14:36 __pycache__

robert@fishhass:/home/homeassistant/.homeassistant/deps/lib/python3.6/site-packages/gmapslocsharing/core$ ls -la
total 44
drwxr-xr-x 2 homeassistant homeassistant  4096 May  8 14:30 .
drwxr-xr-x 3 homeassistant homeassistant  4096 May  8 14:30 ..
-rw-r--r-- 1 homeassistant homeassistant   958 May  8 14:30 config.py
-rw-r--r-- 1 homeassistant homeassistant  9041 May  8 14:30 cookie.py
-rw-r--r-- 1 homeassistant homeassistant 14446 May  8 14:30 location.py
-rw-r--r-- 1 homeassistant homeassistant  2772 May  8 14:30 person.py

The error is now........

Wed May 08 2019 14:36:51 GMT+1200 (New Zealand Standard Time)
Error setting up platform google_maps
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/__init__.py", line 177, 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/homeassistant/.homeassistant/custom_components/google_maps/device_tracker.py", line 54, in setup_scanner
    scanner = GoogleMapsScanner(hass, config, see)
  File "/home/homeassistant/.homeassistant/custom_components/google_maps/device_tracker.py", line 62, in __init__
    from gmapslocsharing import GoogleMaps
ImportError: No module named 'gmapslocsharing'

image

I noticed that. Should I rename the directory created by the script?

Robert Fisher

On Wed, 8 May 2019, 4:30 PM Alex, notifications@github.com wrote:

[image: image]
https://user-images.githubusercontent.com/7096317/57349494-2cb4b800-710f-11e9-856f-a331c29ed565.png


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/home-assistant/home-assistant/issues/17410#issuecomment-490342785,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AL5OPYJVKWXJCJRXYWE5ZJDPUJJM5ANCNFSM4F3K5S7Q
.

depends. if you go to /home/homeassistant/.homeassistant/deps/lib/ and you see a python3.5 folder with a ton of packages in there, then yes.

mv /home/homeassistant/.homeassistant/deps/lib/python3.6/site-packages/googlemapslocsharing /home/homeassistant/.homeassistant/deps/lib/python3.5/site-packages/

and then delete /home/homeassistant/.homeassistant/deps/lib/python3.6 if there's nothing else in there.

There is no 3.5 folder.
Thanks for your help but I think until there is a proper "platform" I will just use (for device tracking) GPSlogger for Android and iCloud for iPhones.

I'm going to lock this issue since it's been closed and there's too much off topic discussion going on. Please don't use the home assistant issue tracker to discuss custom integrations. You're welcome to do that in the forum or chat in the appropriate sections and channels.

Please open a new issue if you still experience issues or think there's a bug.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sh0rez picture sh0rez  ·  3Comments

coolriku picture coolriku  ·  3Comments

sibbl picture sibbl  ·  3Comments

sogeniusio picture sogeniusio  ·  3Comments

flsabourin picture flsabourin  ·  3Comments