Life360 Device Tracker Platform

I would certainly like the option to increase the sample rate based on speed and/or location. My wife has always complained that she gets home and gets in the driveway and gets out of the car before it turns the lights on for her but I’ve always said that was just her phone since mine works just peachy. :grin:

-Tim

Committed version 0.4.0.dev0

Per earlier request, I’m now updating version in manifest.json to help early testers track which update they have. AFAIK, though, HACS cannot “see” these commits (because they are on a branch other than the default branch, and I have not yet started creating actual releases.)

This commit adds the feature to send a Member a location update request in response to the homeassistant.update_entity service call.

From what I’ve seen so far, this will cause the Member’s location to update approximately every 5 seconds for about a minute. However, it is possible for the start of this more frequent update period to be delayed, or not happen at all, depending on how “well” the Member’s phone is “connected to” the Life360 server.

One simple use case could be something like this:

alias: Life360 update location when close - Phil
description: Increase update frequency when Phil is close to home
trigger:
  - platform: template
    value_template: >-
      {% set state = states.device_tracker.life360_phillip_bruckner %}

      {{ state is not none and state.attributes.driving and distance(state) < 1
      }}
condition: []
action:
  - repeat:
      sequence:
        - service: homeassistant.update_entity
          metadata: {}
          data: {}
          target:
            entity_id: device_tracker.life360_phillip_bruckner
        - delay:
            hours: 0
            minutes: 1
            seconds: 0
            milliseconds: 0
      while:
        - condition: template
          value_template: >-
            {% set state = states.device_tracker.life360_phillip_bruckner %}

            {{ state is not none and state.attributes.driving and
            distance(state) < 1 }}
mode: restart

The above was created using the automation UI editor. Here it is in a much more compact form:

alias: Life360 update location when close - Phil
description: Increase update frequency when Phil is close to home
mode: restart
trigger:
  - platform: template
    value_template: >-
      {% set state = states.device_tracker.life360_phillip_bruckner %}
      {{ state is not none and state.attributes.driving and distance(state) < 1 }}
action:
  - repeat:
      while: >-
        {% set state = states.device_tracker.life360_phillip_bruckner %}
        {{ state is not none and state.attributes.driving and distance(state) < 1 }}
      sequence:
        - service: homeassistant.update_entity
          entity_id: device_tracker.life360_phillip_bruckner
        - delay: "00:01:00"
4 Likes

BTW, when it sends the location update request, it will write a DEBUG message to the log saying it has. So, you can search the log for “Sending location update request” to see when it does this.

1 Like

Commited version 0.4.0.dev1

In background task that runs every hour & updates list of Circles and lists of Members in each Circle, once the list of Circles has been retrieved, get the list of Members in each Circle in parallel (instead of sequentially as was done previously.)

1 Like

Can I get a “show of hands”? How many people have been able to use the integration from the new-api branch? How well is it working? Any issues? Any other features you’d like to see?

Unless I’ve forgotten something, I think I have implemented all the features I wanted, and I think I’m ready to start rolling out a beta. I’m also going to start adding more tests, but I don’t want to spend a lot of time on that if it’s still going to change a lot.

3 Likes

I have been using it from the beginning and except for a small problem for the speed that does not come back to zero from time to time, everything works well.

1 Like

All good here Phil - as stable as the old one - dont even notice it is there now and my location based automations are much better!

1 Like

No issues here. Played around with the homeassistant.update_entity last night and could see updates occurring every 5 seconds. Looks great. Thanks for the recent updates!

1 Like

I’m using it with no problems.

1 Like

Just using it for a short time, but no issues so far.

Very happy with it, thanks !

1 Like

all good here too Phil…been using the “new-api” branch since you first mentioned it on here and no issues I’ve seen anyway :+1:

1 Like

I am using with no probs until now…

What problems are you experiencing now?

No, nothing… i mean all is working actually…
:slight_smile:

I just set this up by adding it as a custom repo in HACS, enabling “show beta versions”, and installing 3.10.0.

Saw these errors during initial setup and only had one binary_sensor entity that showed disconnected.

2024-05-02 14:26:12.627 ERROR (MainThread) [custom_components.life360] Error fetching [email protected] data: ClientResponseError: 429, message='Too Many Requests', url=URL('https://api-cloudfront.life360.com/v4/circles')
2024-05-02 14:26:12.733 ERROR (MainThread) [custom_components.life360] Error fetching life360 data: ClientResponseError: 429, message='Too Many Requests', url=URL('https://api-cloudfront.life360.com/v4/circles')
2024-05-02 14:26:22.836 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback DataUpdateCoordinator.__wrap_handle_refresh_interval()
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 250, in __wrap_handle_refresh_interval
    self._handle_refresh_interval(),
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Life360CentralDataUpdateCoordinator._handle_refresh_interval() missing 1 required positional argument: '_now'

I let it sit for about 30 minutes and reloaded the integration. Looks like everything populated then.

The account used is a dummy account I setup without 2FA.

As I believe I’ve mentioned above, the new version has not been released as a beta yet, so it is NOT installable via HACS. You have to install it “manually” (and the readme suggests three different ways to do that.)

0.3.10 is still the old, broken version.

I’ve started the process of getting it ready to be released as a beta. So, you can either try the manual method, or wait for the beta.

Cheese and rice…thought I had added the new instance as a custom repo.

Yes, it would be a custom repo, but there is no new “release” that HACS will see after the really old & broken 0.3.10 release. There are only new “commits” on a branch in github, and HACS can’t see those.

1 Like

That’s the trick. I probably should have crawled back through the posts instead of going off the top of my head. I just remembered a comment about following the install instructions on the readme (probably had more in the comment about using the manual install method).

Downloaded the repo and we’re all good now. Unfortunately, I’m a terrible test user. I only use location for when my wife and I leave and for displaying zone location for us and the kids (that I might look at once a day).

2 Likes

Committed 0.4.0.dev2 through 0.4.0.dev7

0.4.0.dev2 through 0.4.0.dev6 were mostly working on the test infrastructure, although there was one minor bug fix that probably nobody would have noticed.

0.4.0.dev7 removes a bunch of temporary code that 1) checked consistency & validity of some internal data structures, and 2) dealt with changes in stored data (under .storage) to prevent issues as users would update from commit to commit.

Breaking Change

If you are still using something older than 0.4.0.dev6, you should upgrade to 0.4.0.dev6 and restart HA (so the .storage data format is updated) before upgrading to 0.4.0.dev7 (or anything later when available.) Or remove the Life360 integration entry before upgrading, and then add it back after. This is a one-time issue as I prepare for the first beta release.

2 Likes