Life360 Device Tracker Platform

The main issue is changing the Home zone (i.e., zone.home), even though it was an optional feature that the user can decide to use or not. For some reason zone.home is being considered special, even though considering it as such, in my mind, makes no sense, and also prevents solving the main issue people have had using this integration – i.e., Life360 and HA disagreeing when someone is “home.” And as far as I know, the current implementation works just fine; at least it has for me and nobody has complained about problems with it. I thought I made a clear and valid argument to let life360 update the Home zone automatically, but that argument was rejected. At least that’s how I read it. Feel free to read the comments in the PR for more detail.

There is also the issue of complexity when it comes to names of Circles and Members, and how to control which are included and which aren’t. Although every Circle and every Member has a unique ID, that information is not visible to the user. Also, although Members have both first and last names, only the first names are generally displayed. And, if that’s not bad enough, Circle and Member names do not need to be unique, and Members can be in multiple Circles. The configuration options I had in the custom component are probably not up to the task. What’s really needed is a way to present the existing Circles and Members to the user, with Circle membership being clear, during configuration (or re-configuration) so the user can select which to use. I was attempting to use the new config flow stuff, but that doesn’t seem to be up to the task either. Supposedly “options flow” can be used for this, but there’s next to no documentation on how that works.

So basically I need to go back to the drawing board and come up with something simpler.

This may be possible using git commands, but as far as I know it’s not directly supported in github. Even if it could be made to work, I suspect it’s not easy. Nor am I looking for more maintenance tasks. So thanks for the thought, but I don’t think I’ll be going there.

I tend to agree, although I personally like the ability to automatically create HA zones to match Life360 Places. I’ve been using it myself. But I think you’re right that I’ll have to drop the idea of using Life360 Places (even for states – in fact I’ll probably drop the whole show_as_state concept.) or changing HA zones in any way. (FWIW, I’ll probably make myself a tool to create a HA zone YAML file derived from Life360 Places, but I don’t know if I’ll share that. With all the various ways HA can be installed, trying to support something like that is too difficult.)

That does sound like a neat feature, although I suspect that the vast majority of people only define a handful of places such as home, work, school, gym, so it would be fairly trivial for users to recreate those as Home Assistant zones in most cases.

I don’t know if this is possible and/or worth exploring, but maybe you could just dump the users Life360 Places (name + latitude + longitude) in JSON format into the Life360.conf file, kinda like this.

[
  {
    "name": "Work",
    "latitude": "40.7829",
    "longitude": "73.9654"
  },
  {
    "name": "Gym",
    "latitude": "40.7829",
    "longitude": "73.9654"
  }
]

Then when copied and pasted into a site like JSON to YAML they can easily get the YAML output to paste into their zones file. Just a potential idea.

What I came up with is to dump the Places to home-assistant.log (when debug is enabled) in a format that can simply be copied and pasted into a yaml file, especially if you add something like this to your configuration.yaml:

zone: !include zones.yaml

The output looks like this:

2019-05-31 12:16:58 DEBUG (SyncWorker_3) [homeassistant.components.life360.device_tracker] My Family Circle: will be included
2019-05-31 12:16:58 DEBUG (SyncWorker_3) [homeassistant.components.life360.device_tracker] Circle's Places:
- name: Home
  latitude: XX.XXX
  longitude: YY.YYY
  radius: ZZZ

Released 2.10.1

Adjust per some changes coming in the HA 0.94 release, while maintaining backwards compatibility with existing HA releases.

New PRs submitted to make this a standard component. Implementation was simplified over the original proposal.

Code: PR #24227
Doc: PR #9539

Just to be clear, the configuration is different and you’ll need to adjust if/when you move to the standard component. You can see the new config variables, etc. here.

And at some point (assuming it does get accepted as a standard component) I will drop support for this custom component.

Some of the major changes from the custom component:

  • Config is now under life360 as opposed to device_tracker.
  • No support for automatically adding/updating HA zones based on Life360 Places (although there is debug output available that can easily be copied into a yaml file to define zones based on Places.)
  • show_as_state option removed. A new place attribute was added that can be used to determine if the device is located within a Life360 Place. Or, of course, you can manually create HA zones from Life360 Places (as mentioned above), which will effectively do the same thing as show_as_state: places. And there still are driving and moving attributes, too.
  • Due to the above add_zones, home_place & zone_interval no longer exists as options.
  • New circles configuration variable added (and the format of members was changed) which can be used to filter which Circles/Members to monitor.
  • Authentication is no longer cached in a local file (which was by default life360.conf.)
  • error_threshold and warning_threshold are now the values at which warnings & errors will be reported (as opposed to one less.)
  • time_as configuration variable removed (and hence timezonefinderL & numpy packages are no longer required.)
5 Likes

Will the new component be considered a device_tracker by Home Assistant?

Sorry, I guess I don’t understand the point of your question.

Technically speaking, in the current terminology (as I understand it), it will be an “integration”, and it will create device_tracker entities indirectly via the device_tracker, er, whatever-its-called.

Does that mean the time in the sensor will now be displayed in UTC only? If so, is there a way we can convert to local? If not, I’ll stick with your custom component for now :smiley:

Also would like to ask, what’s the shortest interval_seconds we can do?
I have my gpslogger @ 1 second

One more for you. Is it possible to increase/decrease the zone’s radius?
I have automations set based on entering the zones which gives enough time to open the gate etc
Edit: Found out that you can set the radius on a zone in the Life360 app
But unfotunately the max radius is 3.2KM. If I set HA to take all zones from life360, can I add additional zones in HA and build an automation when entering that zone? (in case you’re wondering, I need 10km which is roughly 10 mins from home and HA notifies me if the inside temp is too cold or hot)

Since we’re on that subject, is it a problem if 2 zones overlap each other? I.E 10km out and Home

Thank you so much for all your hard work with this component thus far

Yes, like most things in HA, datetimes will be in UTC, and unless there is some special frontend feature to display it in a different time zone, it will be displayed in UTC.

You could use my composite tracker, even with just one “input” tracker like Life360. It sill has the time_as feature. The downside is it doesn’t take all the attributes from the input trackers, so you’ll lose direct visibility of those.

Technically speaking, it can be negative infinity. :wink: Practically speaking, I guess it depends on your system. Also don’t forget the shorter you make this the more frequently it will be hitting the Life360 server. I personally wouldn’t go any lower than 5 to 10 seconds.

To answer your questions about zones, no, I currently do not provide (nor plan to provide) a way to adjust a zone that is created automatically from a Life360 Place. Yes, you can still create zones in HA (the normal way), even if you have life360 automatically creating zones from Places. No, AFAIK, there is no problem with having overlapping zones. When HA tries to figure out if you’re in a zone, and if so, which one, it has an algorithm to pick the “best” one if the device is in more than one.

I’m not guaranteeing how long I’ll support this custom component after it becomes standard (assuming it does.) I may not delete it, but at some point I won’t work on it to keep it working when things change and it breaks.

1 Like

Shame they wouldn’t include that in the official component, it’s no use for me in UTC because I hate doing the math every time I look at times in the frontend

The shortest I could get it to do was 2 seconds, at 1 second I get ERROR (SyncWorker_11) [custom_components.life360.device_tracker] get_places: ValueError: Attempted to set connect timeout to 0.0, but the timeout cannot be set to a value less than or equal to 0.
I’m assuming it’ll only connect to the servers while driving or moving to get updates every 2 seconds? If not. that’d be a great feature.
I have my gpslogger set to 1 second (with tasker intents) while connected to car BT and 1 hr when not.

On a side note, why does it never show any address for me? They call it the sticks where I live but it’s still on google maps :smiley:

It didn’t for me either so I switched to using the Places Custom Component for addresses (which I think works better for me as it uses the lat/lon from the Composite Device tracker which also takes Google as an input so is sometimes more up to date than Life360).

My guess is that the Life360 server/api isn’t passing it anymore because I am sure it used to work.

Cool thanks. Got a link to that custom component?
I’m currently using google_travel_time component and it’s been great. It would’ve been nice to have that feature in the life360 So I can cut down on components

To be fair, I chose to remove that feature before submitting it. I didn’t want to burden everyone with having timezonefinderL and numpy installed, which are both quite large. Also, it makes more sense to be implemented elsewhere, such as in the Person component (or my composite component. I did this first in life360, then added it to composite. Had I been thinking I probably would only have done it in composite to begin with.)

Oh, yeah, that’s because of how I was setting the network timeout. That is changed in what I’m submitting. But, I’m thinking of making a lower limit of 10 (maybe 5) seconds. This is already using an unofficial API, and I don’t want to do anything to draw their attention to that. If everyone starts hitting their server every second…

No, it always queries the server at the rate requested. Life360 itself, however, I believe updates (the data on the server) more frequently when it detects the device is moving than when it’s stationary. So, in effect, HA will see more updates when the device is moving than when it’s stationary.

That’s a question for Life360. My component just displays what it gets from the Life360 server. I definitely get addresses.

1 Like

Yep.

The thread is old and long but in my experience the CC just works so I’d cut to the chase and go straight to the GitHib page :slight_smile:

Well, I hate to assume… You said that the device would not be defined under device_tracker so I just wanted to verify how the device was going to appear in HA.

1 Like

Ah, ok. I see what you mean. It’s just the configuration that will move.

This is so cool!
I couldn’t find an official component for Life360 (haven’t read all of the 947 comments).
What is the current way of setting up Life360 tracking in HA?
From what I’ve read it has changed over time.

For now see https://github.com/pnbruckner/homeassistant-config/blob/master/docs/life360.md

1 Like