Life360 Device Tracker Platform

The latest of May. 2022.5.5

Actually, I forgot youā€™re using this as a custom integration. (Iā€™ve been working on the PR to submit this formally, so I thought ā€œhomeassistant.components.life360ā€ by default. lol) So, the debug config should be different:

logger:
  default: info
  logs:
    life360: debug
    custom_components.life360: debug

Try again with that. There should be more details in the log this time.

But even with just the details available so far, I can draw a few conclusionsā€¦

First, the ā€œExecutor shutdown has been calledā€ error might be just from when you were trying to stop Home Assistant. Unless that happens often, Iā€™m going to ignore that error for now.

The other error tells me a few thingsā€¦

  • It is able to communicate with the Life360 server.
  • It is able to successfully log into the server.
  • It is able to successfully retrieve the list of Circles.
  • The error happens when it tries to retrieve the Members and their data from one of the Circles (or the only Circle).

Iā€™ve had reports of this problem from time to time for years. But so far Iā€™ve never been able to conclude what causes it. There is some speculation that it has to do with Members not having location sharing enabled, but Iā€™ve tested that scenario and have not been able to duplicate the problem. For more details, see:

and

Are you sure this only happens when you try to use this custom integration version? Or have you seen this problem using the standard, built-in integration as well?

No, iā€™m not sure of this, but never saw those errors before (when using the legacy one).
One question about circlesā€¦ in the app am i forced to have the same circles as the configured zones in HA?

Hmm. Thatā€™s been the problem with these ā€œ400ā€ errors ā€“ they come and go with no rhyme or reason. :slightly_frowning_face:

Sorry, I donā€™t understand the question. Do you mean the same Places as configured zones in HA?

Life360 has Places, and HA has zones. They are separate things. They do not need to agree, although it can help your sanity if they do. See Home Assistant Zones & Life360 Places.

But again, no, they do not need to agree. The state of the device trackers in HA will be solely based on HA zones (and possibly the driving attribute, if you so configure it.) If the device is in a Life360 Place, then that will be shown in the place attribute only.

Yes i was meaning that. Btw your explanation toggle off my doubtsā€¦
I will let you know other logs if they appear.
Thanks for all for now.

1 Like

The PR to convert to the new entity based implementation:

Convert life360 integration to entity based by pnbruckner Ā· Pull Request #72461 Ā· home-assistant/core (github.com)

has been approved and merged, and could, therefore, make it into the 2022.7 (or maybe 2022.8) release.

Note that some features have been removed or slightly modified. See the ā€œBreaking changeā€ section at the top of the PR for a ā€œheads up.ā€

1 Like

The new life360 implementation is in 2022.7.0b0+.

Has anyone using life360 updated to this release, and if so, how is it going?

HA Release 2022.7.0 introduces a BREAKING CHANGE to the Life360 integration

Overview

The Life360 integration has been converted from the old ā€œlegacyā€ implementation (i.e., that uses the known_devices.yaml file in the config directory) to the newer entity-based design, similar to what was done for many other device tracker integrations when the new design was first introduced in release 0.94.0 over three years ago! (Interesting fact: the Life360 integration was first introduced in release 0.95.0, so was implemented while the device tracker component was in the process of being reorganized. So, this change is long overdue!)

When you upgrade to 2022.7 or newer for the first time, all your existing Life360 device_tracker entities will become non-functional. Unfortunately, given the implementation of the device tracker component level code there was no way to avoid this.

But there will also be new entities that are functional.

Take a look on the STATES tab of the Developer Tools page, or the Entities page under Settings, and you should see both the old and new entities. The old entities will have the same entity IDs as before, and so anything that used those entities (person entities, automations, etc.) will no longer be getting updates.

Steps to replace old entities with the new ones

  1. Edit the known_devices.yaml file in your configuration directory to remove any Life360 related entries. Or, if there are only Life360 entries in this file, simply delete the file entirely.
  2. Restart Home Assistant. All the old, non-functional Life360 entities should now be gone.
  3. Go to the Entities page (under Settings ā†’ Devices & Services ā†’ Entities) and change the entity IDs for the new Life360 entities as desired.

Removed/changed functionality

Configuring Life360 via YAML files is no longer supported. Any settings that were in YAML will be automatically migrated to the config entries. Once you upgrade you should remove the Life360 related entries from your YAML files. You can see or change the migrated settings by going to Settings ā†’ Devices & Services ā†’ Integrations and clicking CONFIGURE on a Life360 entry.

Which brings us to the next point ā€“ some settings are no longer supported, specifically:

  • circles
  • members
  • error_threshold
  • warning_threshold
  • max_update_wait (and the corresponding events life360_update_overdue & life360_update_restored)
  • show_as_state: moving

The following attributes have changed:

  • Renamed: battery ā†’ battery_level
  • Removed: moving, raw_speed
5 Likes

Thank you very much, Phil, for your efforts.
My question is for these options which I used to keep in yaml:

life360:
  max_update_wait:
    minutes: 15

  interval_seconds: 12

  show_as_state:
    - driving
    - moving

  accounts:
    - username: !secret life360_ildar_login
      password: !secret life360_ildar_password

What should I do?

  1. Should I simply remove the accounts lines since this info is inputted via UI now?
  2. What should I do with interval_seconds & max_update_wait values since there is no UI input for them?
    image

Here these interval_seconds & max_update_wait attributes are not specified as supported.
OK, assume that interval_seconds is supported by the device_tracker platform.
But what about max_update_wait ?

And what about events ā€œlife360_update_overdueā€, ā€œlife360_update_restoredā€? Are they deprecated?
These events are not mentioned here (as they were before).
But these events are displayed in HA (dev tools):
image

You should remove the entire life360 section from yaml after youā€™ve upgraded to 2022.7.x and the (supported) settings are automatically migrated into the corresponding config entry/entries (in config/.storage/core.config_entries).

I was not allowed to keep support for interval_seconds. It now updates every 10 seconds. If you want it to update at a different rate, then you have to do like youā€™d have to do with any other integration that supports config entries: i.e., click the CONFIGURE button on the integration, then System Options, then disable polling, then create an automation that triggers at the rate you want and have it call the homeassistant.update_entity service with appropriate options.

For max_update_wait and its corresponding events I donā€™t really have an answer. The implementation changed significantly enough that keeping that functionality was not going to be easy, and honestly, I didnā€™t think it would have been used much, and even it it were, it wasnā€™t that important. Since I got no feedback relative to this feature in my ā€œtesters neededā€ topic, or during the beta period, I concluded my assumption was reasonably valid. BUT, if this is a huge problem for you, or others, by all means, open an issue and if there is enough interest I can look into trying to add back the functionality.

The reason those events are shown on the dev tools page is because you have things listening for them, even if thereā€™s nothing in the system that can currently generate them.

Here it is specified as ā€œ12ā€.
Is it an error?

Listening to these events is the ONLY way to set update alert for me.
Earlier these events were generated if there is no any updates from some client within XXXX time.

See, the platform could monitor these updates and set some ERROR flag after that XXXX timeout (like a similar ā€œTraccarā€ platform) - then HA could just monitor this ERROR flag and set/withdraw an alert.
Alternatively, the platform may send events - like the Life360 platform used to doā€¦

For me - both variants will be OK.
But currently we do not have any info ā€œare these data valid or outdatedā€.

I will create an issue for restoring (or replacing) the ā€œalertā€ functionality.
DONE - Life360: restore a functionality to send "overdue/restored" events (or propose a corresponding status) Ā· Issue #74554 Ā· home-assistant/core Ā· GitHub

BTW - removing these events is a BREAKING CHANGE, not mentioned in Release notes.

That does not apply to this integration. That only applies to device tracker integrations that are configured via yaml as a platform under device_tracker:.

The breaking change mentions that max_update_wait is no longer supported. Those events were only generated by using that option. So, no, it does not explicitly say those events can no longer be generated, but I think itā€™s pretty obvious if max_update_wait is no longer supported then you canā€™t expect those events to be generated any more.

For ALL device trackers, they are ALWAYS outdated, except for the instant in time they update (and even then the HA update is probably delayed from when the data was actually generated.) The only question is HOW out of date the data is.

One way, I suppose, to get the same or similar functionality is to use the last_seen attribute. It tells you exactly when the Life360 client on your device last told the Life360 server where it was. If you subtract that from now() you can see how out of date the data is. And you can use that to trigger an automation, and you can even have the action of that automation send the same events and data that the integration used to do. E.g.,:

- trigger:
  - platform: template
    value_template: >
      {{ (now() - state_attr('device_tracker.xxx', 'last_seen'))
         .total_seconds() > 30*60 }}
  action:
  - event: life360_update_overdue
    event_data:
      ...

Thank you @pnbruckner for the instructions, worked perfectly for me!

1 Like

Agree, this is a possible solution.
I am doing the same for a Companion App integration: if a ā€œbattery_levelā€ sensor (the least rough choiceā€¦) is updated more than XXX minutes ago - then the corresponding alert ā€œdata from companion app - not validā€ is set to ON.

Probably I will have to implement a similar functionality for Life360 too.

@pnbruckner

I upgraded to HA 2022.07 on my dev setup, which is where I had made the changes to try your new integration prior to being released. After the upgrade I added the LIfe360 integration then commented out the config.yaml setup and removed the known devices file and restarted. My device_tracker entities appear to be correct as prior however they are showing as ā€œnot_homeā€.

Is there something I missed in the setup? They should be showing as ā€œhomeā€.

**edit - I should also mention no attributes are being shown

Did you back out the test implementation and revert the config before upgrading as I warned you should?

If not, then you should definitely make sure youā€™ve removed the test implementation in your custom_components folder, restart HA, and probably completely delete your Life360 entries on the Integrations page and re-add them because the config entries in the .storage folder are probably bad as I had explained (i.e., wrong version number.)

Let me know if that solves the problem.

So I missed removing the the Life360 folder from the custom_components folder. I have now removed this and restarted HA. If I remove the entities from the integration page how do I go about re-adding them?

You need to delete the integration(s), not the entities. I.e., do this on the Integrations tab, not the Entities tab.

To re-add, click the plus sign in the bottom-right corner of the page, then select Life360 from the list, etc. Youā€™ll need your Life360 account info ā€“ username & password.

Ah, that makes more sense, I thought you wanted me to just delete the entities. Iā€™ll try this.

Sorry, I said ā€œentriesā€, not ā€œentities.ā€ That was a bit confusing I guess. lol!