Life360 Device Tracker Platform

Ok, with this configuration HA zones will be automatically created/updated from any Life360 Places you have defined (including zone.home.)

So basically you’ll be using HA zones (including the ones automatically created/updated from Life360 Places, or any other zones you configured in HA.) And as you say, the device_trackers’ states are being updated as you enter and leave these zones.

You have two choices. First, you can use a state trigger, or you can use a zone trigger. See those links for details and examples.

If you’ve already tried, but it’s still not working, then please post your automation(s) so we can spot what might be wrong.

Hi, if I try to make a binary sensor that goes on if either my girlfriend or me is home:

binary_sensor:
  - platform: template
    sensors:
      wij_thuis:
        friendly_name: "Wij zijn thuis"
        value_template: >
          {{ is_state('device_tracker.life360_anniek', 'home') or
             is_state('device_tracker.life360_jules', 'home') }}

It doesnt work, it does not turn on with just her being home. Doesnt work when I change ‘home’ to ‘Thuis’ either, which is the state life360 actually reports when Im home.

What am I missing here?

EDIT:
nevermind, state is case sensitive…

In HA, the state of device_trackers should definitely be 'home' when you’re home. If it’s not, then you have something misconfigured.

Can you tell me, what do you have for the following options in your HA life360 configuration?

add_zones
zone_interval
home_place
show_as_state

If you don’t have some of these defined in your config, that’s fine since they’re optional. Just let me know that, too.

Oh, and is 'Thuis' the name of your “home” location in the Life360 app/website?

You really shouldn’t post your actual username and password on this public forum. You probably should change your password now.

You should either add this option to your life360 configuration:

    home_place: Thuis

or remove places from show_as_state. EDIT: One or the other, but not both.

Then change your binary_sensor to use 'home' instead of 'Thuis'. This is important because 'home' and 'not_home' are special states for device_trackers.

1 Like

Youre right about the password, changed it.

I will go ahead and implement your suggestions!

Thanks a ton :slight_smile:

1 Like

So currently I have this:

device_tracker:
  - platform: life360
    username: !secret life360_user
    password: !secret life360_pass
    max_gps_accuracy: 200
    prefix: life360
    show_as_state: driving, moving
    home_place: Thuis

binary_sensor:
  - platform: template
    sensors:
      wij_thuis:
        friendly_name: "Wij zijn thuis"
        device_class: presence
        value_template: >-
          {{ is_state('device_tracker.life360_anniek', 'home')
             or is_state('device_tracker.life360_jules', 'home') }}
      hij_thuis:
        friendly_name: "Hij is thuis"
        device_class: presence
        value_template: >-
          {{ is_state('device_tracker.life360_lukas', 'home') }}

But now my binary sensor just says ‘not_home’ while I am in fact ‘Thuis’

EDIT:
It seems not taking out ‘places’ from the show_as_state and only implementing the home_place suggestion seemed to do the trick. Now the life360 devicetracker state gets reported as ‘home’.

1 Like

Huh? A binary_sensor can only be 'on' or 'off'. Did you mean your device_trackers?

Yes, that will work. When I said “One or the other or both” above, I should have said “One or the other”, but not both. :slight_smile:

If you haven’t yet, you should read Home - Home Assistant vs Life360, and review the States chart from the doc page.

In any case, I’m glad you got it working!

1 Like

I recently received the error “Platform not found: device_tracker.life360” after updating to 0.88.2.

-I have the folders reconfigured as custom_components/life360/device_tracker.py
-I deleted the pycache folder
-I copied the most recent code from the github page into my device_tracker.py file.

My original error went away but now I get the following error:

Error setting up platform life360
Traceback (most recent call last):
  File "/config/custom_components/life360/device_tracker.py", line 157, in setup_scanner
    from life360 import life360, LoginError
ModuleNotFoundError: No module named 'life360'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/device_tracker/__init__.py", line 184, in async_setup_platform
    disc_info)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/life360/device_tracker.py", line 161, in setup_scanner
    except LoginError as exc:
UnboundLocalError: local variable 'LoginError' referenced before assignment

Any idea how to fix this?

Thanks!

That seems to imply the life360 python package isn’t installed. That is supposed to be installed automatically. Do you see any errors in home-assistant.log about attempting to install life360?

Try restarting and see if the errors go away. I’ve seen where some people have had issues with HA failing to install requirements (such as this), but after restarting it succeeded and the errors went away.

If that doesn’t solve the problem, and you’re comfortable with running things from the command line (and you’re not hampered by hassio), then we can try to diagnose the problem. Let me know.

I must say that i am having the same type of issue. I have removed and then reinstalled with the custom updater with no joy

Error loading custom_components.life360.device_tracker. Make sure all dependencies are installed

Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/homeassistant/loader.py", line 147, in _load_file module = importlib.import_module(path) File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 962, in _find_and_load_unlocked ModuleNotFoundError: No module named 'custom_components.life360.device_tracker'; 'custom_components.life360' is not a package

Connection lost. Reconnecting…

EDIT: So as not to cause more confusion, I’m deleting my original reply in this post. Seems @ludeeus’s comment below is more on point!

Just wanted to mention that I updated to Hassio 88.2 yesterday and am not having any issue with either life360 or composite trackers loading.

Yeah, custom_updater problems are a different story! :wink:

tip to anyone running docker/hassio and have upgraded from < 0.88.0 you are now running python 3.7, if you get import errors delete the content of the /config/deps/ folder and restart Home Assistant, and it should trigger a re-installation of external python packages.

1 Like

Ah, that would seem to definitely explain these new issues that came out of the blue. Wow, thanks for the info!! :slight_smile:

@pnbruckner Thanks for your help, back up and running. Cheers :+1:

Can you explain what you did? Did you change the folder name, or did you do as ludeeus suggested? If the former, and you’re using docker/hassio, then you should probably put it back the way it was and try ludeeus’ suggestion instead, otherwise you may get bit again in the future.

I deleted the folders that ludeeus suggested and rebooted. However still have the same issue.

I renamed the folders as you suggested and it started working.

BTW I am using Hassio.

I did just rename the folder back to normal and rebooted for sanity sake and I still have the issue.

Well, this isn’t good. If I were you I’d try to get to the bottom of it. E.g., do you see any errors in home-assistant.log about failing to install life360? (You may have to stop HA, delete that folder and try again, because the errors, if they existed, might be gone, depending on if you restarted since the first time you did that.) Or can you run pip3 list from a command line to see what packages are installed? The problem is, I don’t use hassio so I’m not sure what you can and can’t do, and how.

The problem might be due to that change in the loader I mentioned previously. If that’s the case, then maybe you can keep the temporary folder renaming until 0.89 comes out. Still, would be nice to know for sure what the problem really is.

I just created a fresh install of 0.88.2, using Python 3.7.2. I installed custom_updater (4.2.16) and used it to install element “device_tracker.life360”. After restarting (and adding a basic life360 device_tracker config) it seems to work just fine. It would appear that you have some kind of unique issue. I’m not sure what to tell you.

Thanks! A restart fixed it. I had restarted after updating the device_component.py file. I suppose an additional restart was all it needed.