Life360 Device Tracker Platform

saying username is wrong. That is the email address you set it up with. I know it is right.

    2019-03-18 09:19:40 WARNING (MainThread) [homeassistant.loader] You are using a custom component for life360.device_tracker 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.
2019-03-18 09:20:03 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform life360
Traceback (most recent call last):
  File "/config/custom_components/life360/device_tracker.py", line 158, 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 162, in setup_scanner
    except LoginError as exc:
UnboundLocalError: local variable 'LoginError' referenced before assignment

CORRECTION! working now. Thank you!

1 Like

Just wanted to start off by saying, thanks for all the work on this component. I use this along with google location sharing and your composite tracker, and pretty much have had perfect presense detection for months.

I have a quick question, I think it’s more of a life360 question than a component question. What contitues “moving”. I have an automation I’m trying to improve that locks my car doors when I’ve parked (in case I forget to do it manually). Currently I use zones for this, but I dont want to set up a zone for every place I could go to.

So I was thinking when driving changes to false, but then thought, what if I was in very slow traffic. I dont know what the threshold is for driving to go to false. Like let’s say waiting in a fast food line for 10 minutes. That would prob be driving false, but what about moving? Or parked at a mall, then walking around the mall. I figure that would definitely be moving. right? How far do I have to move to count as moving? Just trying to determine what would be the best solution.

The moving attribute is not processed at all by my code. This status comes strictly from the Life360 server. The situation is a bit more involved for the driving attribute. Like moving it does come from the Life360 server, but it can be overridden by my code if you specify driving_speed in your life360 configuration. Then, of course, whether or not the device_tracker’s state is changed to Moving or Driving depends on your show_as_state config.

Bottom line, I think you’ll just have to see how these values behave over time.

1 Like

Thanks. Makes sense. I have driving set to 12 MPH, I don’t use any custom show_as_state options, and will pull just the moving/driving attributes directly. I did use moving, driving, etc when I first started using the component, but it ended up causing me to have to tweak too many of my other automations that relyied on home/not_home. I think I’ll create a temp automation to send me a message everytime life360 reports me as moving, when I’m not driving. That will help out a lot.

Thanks again for the info

edit:
Not tested yet, but here is the automation I suspect should do what I’m looking for

- alias: Moving but not driving
  trigger:
    platform: template
    value_template: "{{is_state_attr('device_tracker.paul', 'moving', true)}}"
  condition:
    condition: template
    value_template: "{{is_state_attr('device_tracker.paul', 'driving', false)}}"
  action:
    service: notify.pushbullet_notifications
    data_template:
      target:
      - !secret pauls_secret_email
      title: "Moving but not Driving"
      message: "Moving but not Driving"
1 Like

My “home” radius in the life360 app is set at 995 feet, so right at 300M. I’ll try changing the polling period. Just today when my wife was coming home my Life360 app on my phone notified me that she was home right about 1 minute before she showed up as home in HA. So, the delay must be somewhere between HA communicating with Life360.

I very recently started using the HA Person component to see if we are home. It is tracking the Life360 device tracker and when my phone connects to WiFi.

Edit: I just checked my polling interval at it has been set to 6 seconds.

Have you read this from the doc page that explains the relationship between Home in HA and Home in Life360, and provides suggestions for how to configure things?

Just replying to my own post. This worked for me today. Had to leave my office on foot for a bit. Walked a couple hundred feet from my normal work location. Sure enough, I got the alert. So, now just to decide what to do with this new informaiton. :slight_smile:
Thanks again

1 Like

well, have it update your work proximity and calculate the time needed to walk back to the office :wink:

1 Like

Thanks! I’ve implemented all 3 of those tips. Hopefully that helps.

Released 2.9.0

This release bumps the life360 package to 3.0.0, which now stores in the cache file (typically life360.conf), along with the authorization string, the credentials used to obtain it, and when loading the cache file (after HA restarts) will check to see if the credentials have changed. If so, it will discard the cache file and reauthorize, writing the new information to the cache file.

Note that the format of the cache file has changed, so after updating, the first restart will generate a warning that looks like this:

2019-03-21 10:08:43 WARNING (Thread-10) [life360.life360] Authorization cache file out of date. Reauthorizing

I upgraded HA to 0.90 the other day. Life 360 is really glitchy. Made sensor templates for battery, device info and distance from home and they do not update unless I restart HA.

What version of the custom life360 component are you using? Also, can you share your template sensors? Have you looked in home-assistant.log to see the life360 activity? E.g.,:

grep -F -e '[custom_components.life360.device_tracker]' -e '[life360.life360]' -e 'new_state=<state device_tracker.' home-assistant.log

E.g., I see this:

2019-03-23 08:45:24 WARNING (SyncWorker_16) [life360.life360] Authorization cache file out of date. Reauthorizing
2019-03-23 08:45:25 DEBUG (SyncWorker_16) [custom_components.life360.device_tracker] Setup successful!
2019-03-23 08:45:25 DEBUG (SyncWorker_16) [custom_components.life360.device_tracker] Configured members = None specified; will include all
2019-03-23 08:45:25 DEBUG (SyncWorker_16) [custom_components.life360.device_tracker] Checking Places
2019-03-23 08:45:25 DEBUG (SyncWorker_16) [custom_components.life360.device_tracker] Updating zone from Place: Home: ...
2019-03-23 08:45:25 DEBUG (SyncWorker_16) [custom_components.life360.device_tracker] Adding zones from Places: ...
2019-03-23 08:45:25 DEBUG (SyncWorker_16) [custom_components.life360.device_tracker] Updating me
2019-03-23 08:45:25 DEBUG (SyncWorker_16) [custom_components.life360.device_tracker] Updating wife
2019-03-23 08:45:25 DEBUG (SyncWorker_16) [custom_components.life360.device_tracker] Updating daughter
2019-03-23 08:47:27 DEBUG (SyncWorker_12) [custom_components.life360.device_tracker] Updating daughter; Time since last update: 0:19:36

EDIT: Oops, I didn’t have debug set for homeassistant.core. When you do you’ll also see state changes (with all the attribute detail) for your device_tracker entities.

I just updated to 2.9.0 yesterday.

In the log I do not see anything about Updating zones or members like you have.

Here is my sensors for myself:

  - platform: template
    sensors:
      daves_iphone_battery:
        value_template: '{{float(state_attr("device_tracker.life360_dave","battery"))}}'
        unit_of_measurement: '%'

  - platform: template
    sensors:
      daves_iphone7_distance:
        value_template: '{{float(state_attr("device_tracker.life360_dave","distance"))}}'
        unit_of_measurement: 'km'

  - platform: template
    sensors:
      daves_iphone7_info:
        value_template: '{{float(state_attr("device_tracker.life360_dave","info"))}}'

  - platform: template
    sensors:
      daves_iphone7_battery_status:
        value_template: '{{float(state_attr("device_tracker.life360_dave","battery_status"))}}'

Hi @Dayve67

I was looking at the github information of this Device Tracker, but I don’t see the three of the four attributes you’re showing in the code of your last message

battery_status
info
distance

I tried to define same sensors, but only battery is working.

How can I define the others?

Thanks

Sorry woody I posted from my old setup. Here what it should be:

  - platform: template
    sensors:
      daves_iphone_battery:
        value_template: '{{float(state_attr("device_tracker.davesiphone7","battery"))}}'
        unit_of_measurement: '%'

  - platform: template
    sensors:
      daves_iphone7_distance:
        value_template: '{{float(state_attr("device_tracker.davesiphone7","distance"))}}'
        unit_of_measurement: 'km'

  - platform: template
    sensors:
      daves_iphone7_info:
        value_template: '{{float(state_attr("device_tracker.davesiphone7","info"))}}'

  - platform: template
    sensors:
      daves_iphone7_battery_status:
        value_template: '{{float(state_attr("device_tracker.davesiphone7","battery_status"))}}'

I’m also using the IOS app for device tracking. If you are too look in your States and under entities for your device tracker of your Iphone you should see two device trackers. On the right side is all the attributes of the device tracker. You can pull and use anyone of them with a template sensor. Note that I’m not using the Life360 device tracker for the sensors.

image

Thanks

So what device tracker are you using?
I’m using also Google Maps, but does not show all this attributes

Sorry for this OT

Hey no problem. I have tried all kinds of trackers. the best I have found is Icloud3 and Life360. I use both of them together. Kind of like a fail safe. Check out Icloud3. https://github.com/gcobb321/icloud3

1 Like

@pnbruckner
I’m sorry. I was looking at the wrong device tracker when I said Life360 was not updating. Looking into now it is the Icloud3 that was causing the problem. Thanks

No problem. Glad you figured it out.

It may not matter anymore, but I would guess, if you’re not seeing these messages, you don’t have logger set to debug for this component.