Life360 Device Tracker Platform

I wanted to try the new offical component but always get an “Unknown error occured” message. Username (E-Mail) and Password are correct.

l360

Log:

Log Details (ERROR)
Fri Jun 28 2019 15:56:36 GMT+0200 (Mitteleuropäische Sommerzeit)
Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 160, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw)
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/connection.py", line 57, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/local/lib/python3.7/socket.py", line 748, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name does not resolve

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 603, in urlopen
    chunked=chunked)
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 344, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 843, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 316, in connect
    conn = self._new_conn()
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 169, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7f894e739278>: Failed to establish a new connection: [Errno -2] Name does not resolve

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 670, in urlopen
    **response_kw)
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 670, in urlopen
    **response_kw)
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 641, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py", line 399, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.life360.com', port=443): Max retries exceeded with url: /v3/oauth2/token.json (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f894e739278>: Failed to establish a new connection: [Errno -2] Name does not resolve'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/life360/life360.py", line 59, in get_authorization
    headers={'Authorization': 'Basic ' + api_token})
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 581, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.life360.com', port=443): Max retries exceeded with url: /v3/oauth2/token.json (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f894e739278>: Failed to establish a new connection: [Errno -2] Name does not resolve'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
    resp = await task
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/real_ip.py", line 33, in real_ip_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 67, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 216, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 115, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 155, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 46, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 86, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 87, in async_configure
    flow, cur_step['step_id'], user_input)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 123, in _async_handle_step
    result = await getattr(flow, method)(user_input)  # type: Dict
  File "/usr/src/homeassistant/homeassistant/components/life360/config_flow.py", line 51, in async_step_user
    self._username, self._password)
  File "/usr/local/lib/python3.7/site-packages/life360/life360.py", line 66, in get_authorization
    err_msg = resp.json()['errorMessage']
UnboundLocalError: local variable 'resp' referenced before assignment

Seems like you’re having a networking issue. It’s not able to do a DNS lookup of api.life360.com. I’ll look into why the error wasn’t handled more cleanly.

EDIT: Found why the exception wasn’t caught. I’ll fix it and do another PR. However, the end result would be the same for a DNS error (just the error message would be a bit more useful.) You need to solve the network issue. Or maybe it’s just temporary.

EDIT 2: PR submitted.

Do you see a line above that that starts with the following?

Error while getting authorization token: xxx

No, not really. I just tried to disable Adguard Home but it still doesn’t work. I am currently accessing from Remote UI (NabuCasa Cloud). I will try locally when I get home

Thanks for the awesome component, glad it is now included in HA. I only say this for the benefit of future web and site searches - the title on this article says “Life306” instead of “Life360”. Thanks again!

1 Like

What article? Where do you see that?

Not sure why it put my comment over here - if you go directly to this url and look at the second bold heading that’s where it is

LOL! That’s my bad. Thanks, I’ll fix it.

So I just did a test. I did a completely fresh install of 0.94.4, then added the custom life360 and got that working. Then I followed my transition instructions and it worked as expected.

Then I tried the experiment again, but this time leaving the life360 folder in place and changing its name to life360.bak. Otherwise I followed the transition instructions, and it still worked just fine.

So something weird is happening sometimes, because unfortunately I don’t think yours has been an isolated case. Also unfortunate, though, is I have no idea why it’s happening, or more importantly, how to avoid/fix it.

1 Like

silly thing, try and rename your folder to something that does not look like an extension? like maybe life361?

Why would that matter, especially on Linux?

EDIT: Hmm, maybe a Python import thing??? I’ll try the experiment again, but this time rename it to life360x, which is what I think I used before. I can also try it one more time by moving the folder. When you said you moved it “completely outside of the CC folder”, you didn’t happen to move it into the HA config directory by any chance, did you? If you did, then that would be a problem and has bitten others before.

I agree it shouldn’t, but then it would not be the first time I see weird things happen…
And that appears to be the only difference with what I’ve done

And yes I left the folder in the /config directory

What do you know about the Grafana / InfluxDB integration of HA?
Do you (at the platform level) determine the field type being sent to the InfluxDB?

When I query the lat and long, they come up as
latitude: 34.07
longitude: 84.27

instead of the correct coordinate
latitude: 34.0711234
longitude: -84.2761234

Yeah, that would be a problem. Although it should not find that as a custom component, it will find it when looking for the pypi.org package by the same name. So you should definitely not move <config>/custom_components/life360 to <config>/life360.

Not much, other than I believe they are used via the same package, so from a HA perspective, it shouldn’t matter. I use MariaDB on my “production” system, and sqlite when testing.

Exactly how are you querying for lat & lon?

Or, wait. Do you mean you use those databases for HA’s recorder? Or are you using them some other way? If so, I don’t know anything about that.

I’m using the regular query entry in Grafana

In MariaDB, are the entries showing up with the full lat and long coordinates?

it would appear (in mysql at least) that HA stores the data as is, without trunking floats to 2 decimals.
I don’t track entities that have more than 2 decimals so I don’t know if the issue is HA export, InfluxDB Import or Grafana Import/display…
Silly question: have you tried to change the decimals in Grafana?

1 Like

So exactly how are you using Grafana? Is it HA’s recorder database? Or is it pulling from HA’s recorder database somehow?

When I do a query of my MariaDB database (which is HA’s recorder database) in mysql, like this:

MariaDB [homeassistant]> select attributes from states where entity_id = 'device_tracker.phil';

The attributes data (which has, of course, been JSON serialized), has the full resolution for both latitude & longitude.

damn decimals… completely missed that :slightly_smiling_face:
thanks

1 Like

Phill,

Grafana is usually linked to InfluxDB for visualisation.

Check this out