Life360 conversion to entity-based device tracker - Testers Needed

Ok, found and fixed both bugs, and released as version 0.0.2.

I had recently been focusing my testing on upgrading a system that already had Life360 config entries and forgot to go back and test adding an entry on a system that did not have any existing entries.

THANKS! Let me know if this fixes the problems for you.

So far so good. everything installed correctly.

I’ll watch it over time to see how the old one vs the new one compares.

1 Like

I have been using this for a few days now and everything seems to be reporting correctly. The attributes all seem to match my current prod version. No issues so far.

1 Like

Completely convinced this will be my doing, removed my previous set up and followed your instructions but on configuring I get a translation error - any pointers would be appreciated - I wondered if its referring to the documentation link which is pointing my instance of HA in the absence of anything else?

Translation Error: The intl string context variable “docs_url” was not provided to the string “To set advanced options, see Life360 documentation.
You may want to do that before adding accounts.”

image

Hmm, that looks a bit weird. But, no, I don’t think it’s anything you’re doing wrong.

First off, I should probably have mentioned that I only provided English translations in the test project. I have no idea how to get all the translations. That’s something that happens automagically for built-in integrations. I don’t know how to do it for a custom integration.

Having said that, it appears to be trying to use the strings JSON file(s) from the built-in integration, not the custom integration (because the custom one doesn’t have the string “To set advanced…”.) I.e., I’m assuming your system is configured for a different language. So, HA tries to find the corresponding .json file in custom_components/life360/translations, but when it doesn’t find it, it then tries finding it in homeassistant/components/life360/translations and finds it. But that’s the wrong one!

Bottom line, I don’t know how to provide all the language translations for the test custom integration, so either you’ll need to temporarily reconfigure your system to English, which I doubt you’ll want to do, or I guess you can’t use this.

Or, maybe you could copy custom_components/life360/translations/en.json to an appropriate xxx.json file (into custom_components/life360/translations.) At the very least it should work (but the strings will still be in English, unless you want to convert them in the xxx.json file.)

Does that make sense?

1 Like

I was in English but it was English (GB). Switching to straight English fixed that, thanks for the quick response!!

1 Like

Installed tonight using the “Install, run and reconfigure” instruction and everything working fine first time.

Thanks for the work on this Phil :+1:t2:

1 Like

Pull request submitted:

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

1 Like

Maybe i posted this to the wrong place…
Please read it.

Hi. I’m getting an error: Retrying setup: ‘NoneType’ object is not subscriptable.

From the log details:
This error originated from a custom integration.

Logger: custom_components.life360
Source: custom_components/life360/helpers.py:171
Integration: Life360 (documentation, issues)
First occurred: 11:14:19 PM (5 occurrences)
Last logged: 11:16:15 PM

Unexpected error fetching life360 ([email protected]) data: ‘NoneType’ object is not subscriptable
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py”, line 191, in _async_refresh
self.data = await self._async_update_data()
File “/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py”, line 150, in _async_update_data
return await self.update_method()
File “/config/custom_components/life360/init.py”, line 154, in async_update_data
return await get_life360_data(hass, api)
File “/config/custom_components/life360/helpers.py”, line 171, in get_life360_data
place = loc[“name”] or “None”
TypeError: ‘NoneType’ object is not subscriptable

Is it possible one of the Circle Member’s phone is offline?

I had a test for this condition in the original “legacy” implementation, but got rid of it. I guess I need to add it back in.

Thanks!

Released 0.0.3

Adds check for missing location information (like legacy integration used to do.)

@Rudysmama let me know if this eliminates the exception (and adds a proper error message to the log.) Thx!

2 Likes

@pnbruckner I am no longer getting the error! Thanks for the quick response. Now if I can figure out how to pull the battery data for my dashboard purposes. :slight_smile: Thanks again.

To all who have tried this out:

First, thank you again! You have caught at least two bugs that probably would have affected many users. I very much appreciate it!

Second, the implementation in the PR submitted for the official built-in integration has changed such that the version number for the config entry storage is not changing from 1 to 2 (as in my initial implementation, which this custom integration version uses.) That means you will definitely need to back out this change from your system (and restore the configuration & known_devices.yaml) before upgrading HA to the version that will (hopefully) eventually contain the updated integration (i.e., once the PR is approved and merged.)

1 Like

Glad to hear it, and thanks for exposing this bug. I think I already knew I needed to fix this, but it helps to get verification.

BTW, there still should be an error, right? I mean, instead of the exception there should now be a “proper” error message in the log. Do you see one? If so, I’d be really interested to know exactly what it says.

As far as pulling out the battery data:

sensor:
  - platform: template
    sensors:
      phone_battery:
        friendly_name: Phone battery
        value_template: "{{ state_attr('device_tracker.XXX', 'battery_level') }}"
        unit_of_measurement: "%"

Or in the new format:

template:
  - sensor:
      - name: Phone battery
        unit_of_measurement: "%"
        state: "{{ state_attr('device_tracker.XXX', 'battery_level') }}"

Thank you for that info. Sorry for the delayed response.
Here is the error in the log for the user that is no longer using Life360.

1 Like

UPDATE: PR has been approved and merged. Therefore these changes may make it into the 2022.7 release.

REMINDER: Back out this custom integration and restore your config before you update to the HA release with the new life360 implementation (whatever release that ends up being.)

1 Like

The new life360 implementation is in 2022.7.0b0+. Has anyone given it a try?

That’s great news.

Haven’t tried it yet, but will do when I get a chance to update.

1 Like