Life 360 support

What version of Home Assistant are you running?

I’m running 0.65.6. For the sake of transparency, I just installed your add-on today and first got the same error as HITChris, then now the new error. So I’ve never had a working instance of the addon.

I can see in the addon’s Log the response code and it’s accurate, but the front-end only displays “away” for all family members, which is not the case.

Same here…

Are you also seeing ‘Unknown Home-Assistant API access!’?

Under the system log - yes

I’m not seeing that.

Version 12 is building now, you should see it and, in theory, it should fix the issue :slight_smile: If not let me know and I will take a look

That did it. Thanks again @editter

I’m no longer getting the @ data errors. But I still get the Unknown API Access error after updating to .12.

Here are my configurations. Sensitive info has been replaced with placeholders.

Add-on:

{
  "process_type": "HTTP",
  "mqtt_host": "",
  "mqtt_port": 0,
  "mqtt_username": "",
  "mqtt_password": "",
  "preface": "",
  "cert_file": "fullchain.pem",
  "key_file": "privkey.pem",
  "host_url": "https://myhass.duckdns.org:8081",
  "refresh_minutes": 1,
  "user_device_map": [
    {
      "life360_name": "Me",
      "known_devices_name": "me_phone"
    },
    {
      "life360_name": "Wife",
      "known_devices_name": "wife_phone"
    }
  ],
  "life360_user": "[email protected]",
  "life360_password": "my_password"
}

Known Devices:

me_phone:
  track: yes
  hide_if_away: no
  name: Me
  
wife_phone:
  track: yes
  hide_if_away: no
  name: Wife

configuration.yaml:
device_tracker:

Nice addon, hope to be getting it running soon. I’m getting the following error when I start the addon and haven’t been able to identify the root cause

info: No previous state found, setting to defaults.
3/25 2:31:16 pm - error: Error getting initial token request. Ending process
3/25 2:31:16 pm - error: Error: getaddrinfo EAI_AGAIN api.life360.com:443
at Object._errnoException (util.js:1024:11)
at errnoException (dns.js:55:15)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:92:26)

and these are my settings

{
“process_type”: “HTTP”,
“mqtt_host”: “”,
“mqtt_port”: 0,
“mqtt_username”: “”,
“mqtt_password”: “”,
“preface”: “”,
“cert_file”: “”,
“key_file”: “”,
“host_url”: “http://111.111.2.111:8081”,
“refresh_minutes”: 1,
“user_device_map”: [
{
“life360_name”: “me”,
“known_devices_name”: “my_phone”
}
],
“life360_user”: “[email protected]”,
“life360_password”: “**********”
}

This looks like there is an issue with your Life360 credentials. Everything else seems like it should work.

Hmmm, that is odd. Can you try restarting the whole HA instance?

I’ve restarted it a couple of times since my last post. Most recently this morning. Same result. I’ve even uninstalled both the add-on and repo, and re-installed before that. When the add-on starts, I see positive and accurate response data. But within HA the devices continue to all show away in error, and the unknown API access error in the hassio system tab.

I sorted it out. I still get the Unknown API access error. But the issue with the devices showing AWAY was that the longitude/latitude was not accurate for my house (I’m ashamed to admit). Once I adjusted that, it started to display correctly.

I double checked the credentials and they are correct, tried with the phone # and email address, still getting the same error. Not sure what else to try.

There seems to be a DNS error which is a new one to me. Can you navigate to this url in your browser? https://api.life360.com/v3/ It should show a 404 error but the Life360 logo should appear in the upper left.

No problem getting to it, I saw the 404 and their logo on the left-hand side.

Edit: I turned off my VPN and that had no effect on it.

FWIW, here’s an update. It now updates all members in all circles (although I only have one circle :slight_smile: ), and it only updates a member if the timestamp from the member’s location data is newer than the last update.

from requests import HTTPError
import logging
import voluptuous as vol
from homeassistant.components.device_tracker import (
    PLATFORM_SCHEMA, CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL)
from homeassistant.const import CONF_USERNAME, CONF_PASSWORD
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.event import track_time_interval
from homeassistant import util

_LOGGER = logging.getLogger(__name__)
_AUTHORIZATION_TOKEN = 'cFJFcXVnYWJSZXRyZTRFc3RldGhlcnVmcmVQdW1hbUV4dWNyRU'\
                       'h1YzptM2ZydXBSZXRSZXN3ZXJFQ2hBUHJFOTZxYWtFZHI0Vg=='

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_USERNAME): cv.string,
    vol.Required(CONF_PASSWORD): cv.string
})

def setup_scanner(hass, config, see, discovery_info=None):
    from pylife360 import life360
    api = life360(_AUTHORIZATION_TOKEN,
                  config[CONF_USERNAME], config[CONF_PASSWORD])
    if not api.authenticate(timeout=10):
        _LOGGER.error('Authentication failed!')
        return False

    _LOGGER.info('Authentication successful!')
    interval = config.get(CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL)
    Life360Scanner(hass, see, interval, api)
    return True

class Life360Scanner(object):
    def __init__(self, hass, see, interval, api):
        self._hass = hass
        self._see = see
        self._api = api
        self._dev_prev_update = {}
        track_time_interval(self._hass, self._update_life360, interval)

    def _update_life360(self, now=None):
        _LOGGER.debug('Checking members.')
        try:
            for circle in self._api.get_circles(timeout=5):
                for m in self._api.get_circle(circle['id'], timeout=5)['members']:
                    dev_id = util.slugify(
                        '_'.join([m['firstName'], m['lastName']]))
                    loc = m['location']
                    last_update = util.dt.utc_from_timestamp(
                        float(loc['timestamp']))
                    prev_update = self._dev_prev_update.get(dev_id)
                    if prev_update is None or last_update > prev_update:
                        msg = 'Updating {}.'.format(dev_id)
                        if prev_update is not None:
                            msg += ' Time since last update: {}.'.format(
                                last_update - prev_update)
                        _LOGGER.debug(msg)
                        self._dev_prev_update[dev_id] = last_update
                        lat = float(loc['latitude'])
                        lon = float(loc['longitude'])
                        loc_name = loc['name']
                        # Make sure Home is always seen as exactly as home,
                        # which is the special device_tracker state for home.
                        if loc_name is not None and loc_name.lower() == 'home':
                            loc_name = 'home'
                        attrs = {
                            'last_update' : str(util.dt.as_local(last_update))
                        }
                        self._see(dev_id=util.slugify(dev_id.replace('-', '_')),
                                  location_name=loc_name, gps=(lat, lon),
                                  gps_accuracy=round(float(loc['accuracy'])),
                                  battery=round(float(loc['battery'])),
                                  attributes=attrs)
        except HTTPError as exc:
            _LOGGER.error('{}: {}'.format(exc.__class__.__name__, str(exc)))
1 Like

@editter, did you get a chance to look at the webhooks? I still haven’t seen them fire in the last couple of months. I ended up increasing the zone’s size as you’d suggested, but the zone-based automations I have running are somewhat inconsistent due to their reliance on minute-to-minute polling. Thanks again for supporting this as time permits.