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

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

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 4
  • Comments: 130 (18 by maintainers)

Most upvoted comments

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

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…

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.

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

there we go…

image

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

@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.

@WedHumpDay how bout them fuckin’ apples? image

fucking lol image

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

@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.

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 home-assistant@homeassistant.service


#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 home-assistant@homeassistant.service

#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.

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

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…

@sherbang Thanks that worked just fine!

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?

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.

bummer…

image

image

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.

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.

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.