Life360 Device Tracker Platform

See the discussion in my first attempt at getting it accepted.

UGH, what a brutal readā€¦ Its good to know what happenedā€¦ I can configure zones and just move on :slight_smile:

I think part of the problem was the core team knew they wanted to enhance the handling of the home zone, and what I had done didnā€™t fit that model, that, of course, didnā€™t exist yet. But now that it does, maybe I can try again, using the new service specifically for ā€œmovingā€ the home zone. Iā€™ll add it to my list. No promises, though. :slight_smile:

1 Like

My stuff is working pretty good right now and the G/F stopped complaining once I updated the zones. Manual Zone building is a little tedious but it allows for very granular control.

1 Like

Which is one of the reasons I also provided zone adding/updating as a service. You can then do it if/when you want, on demand. Of course I only registered the service if you had the automatic feature enabled. I guess if I do end up trying to add zone support again, Iā€™ll just always register the service.

2 Likes

Iā€™m assuming that I know the answer to this but just to be sureā€¦

Is it OK to remove the life360.conf file now that I have switched to the integration?

Yes, it is no longer used.

1 Like

ok thanks, just updated to 95.4

see this in the log:

2019-07-01 14:31:11 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform legacy
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/device_tracker/setup.py", line 76, in async_setup_legacy
    tracker.see, discovery_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_custom/device_tracker.py", line 298, in setup_scanner
    zones_from_places_interval()
  File "/config/custom_components/life360_custom/device_tracker.py", line 288, in zones_from_places_interval
    zones_from_places(api, home_place_name, add_zones, zones)
NameError: free variable 'api' referenced before assignment in enclosing scope

none of my device_trackers is working anymoreā€¦
should I maybe rename the device_trackers too, so they wonā€™t interfere with the integration (which I havenā€™t setup yet)

device_tracker:
  - platform: life360_custom
    username: !secret life360_username
    password: !secret life360_password
    prefix: life360
    show_as_state: places, driving, moving
    driving_speed: 20
#    interval_seconds: 12
    max_gps_accuracy: 200
    max_update_wait:
      minutes: 10
    add_zones: only_home
    time_as: device_or_local
    warning_threshold: 1
    error_threshold: 2

is the config I use for now.

setting up the new integration seems to be successful but when clicking the integration tab out of view, I see the bell:

02

@Mariusthvdb you need to read the breaking changes. Life360 is no longer a Custom Component. The configuration moved from device_tracker: to life360:. Life360 integrations are now Built into Home Assistant. Because of this change Life360 is now subject to follow the guidance of the core team regarding things like Zones/Places. Life 360 Places are no longer imported so you will need build out the Zones that you used for triggering automation. My migration took about an hour and all was good. see the post below for guidanceā€¦

Transition from custom to standard integration

I canā€™t exactly explain the error youā€™re seeing, nor why it started with 0.95.4. But there is one thing that can still cause the old custom integration and the new standard integration to step on each otherā€™s toes, and that is the use of hass.data. They both put data in hass.data['life360'], but different data. So if you want to try and keep the old custom integration limping along, then in this line in device_tracker.py of the old custom integration:

DATA_LIFE360 = 'life360'

change 'life360' to match whatever folder name youā€™re using in <config>/custom_components/.

That should help prevent the two instances of life360 from interfering with each other. But it might not solve the overall problem.

fully aware of that, and donā€™t use places in my integration setup. Aamof, I wasnā€™t using the integration yet, and rebuilt the original CC to a custom_cc, as discussed with Phil, few posts earlier.

Having said that, Ive now also setup the new integration, and neither of them workā€¦

added the suggestion Phil did here:

so hope that solves it, because I love the options the original CC gave us.

Never used places, so that could have been left out completely, only use home/not_home and the HA zones.

will report back if things get better (or notā€¦)

update
not better:

2019-07-01 16:55:07 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform legacy
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/device_tracker/setup.py", line 76, in async_setup_legacy
    tracker.see, discovery_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_custom/device_tracker.py", line 298, in setup_scanner
    zones_from_places_interval()
  File "/config/custom_components/life360_custom/device_tracker.py", line 288, in zones_from_places_interval
    zones_from_places(api, home_place_name, add_zones, zones)
NameError: free variable 'api' referenced before assignment in enclosing scope

There has been some inexplicable behavior observed when simply renaming <config>/custom_components/life360 to something else, either ā€œin placeā€ or moving the folder elsewhere. It seems this can somehow lead to the standard integration failing. However deleting the folder solves the problem. Again, canā€™t explain it. But, ā€¦

If you canā€™t get things working, then try actually deleting the folder that contains the custom life360 integration, no matter what itā€™s currently called or where it is currently located. Then restart HA and see, as a temporary test, if you can get the standard integration to work. If so, then delete the standard integration and try re-installing the custom life360 into <config>/custom_components/life360cc, and donā€™t forget to change to DATA_LIFE360 = 'life360cc'. Then see if you can get that working again.

Of course, by this I meant go to the Integrations page, click on the Life360 integration, then click the delete button. I didnā€™t mean delete the standard life360 integration code. :blush:

I removed the life360 folder and changed the device tracker configuration in the configuration.yaml, but when I updated I see all members away even when theyā€™re home. Is there another thing I need to do?

Did you follow all the transition instructions? Go back over the instructions, in detail, and make sure. If youā€™re still having problems after that, try one more restart, and if that doesnā€™t fix the problem, let me know.

no worriesā€¦

deleting the CC folder at least kicked my newly setup integration to life. And, if this would follow the regular HA Zones, as the device_tracker component should, I might as well leave it at thatā€¦

my App daemon App adds all the other attributes nicely, so maybe that suffices for the now.

Only thing I could wish for (next to the zones) is the former time_as:, which I found a very nice touch to the device_tracker Custom component.

If youā€™re not using the add/update zone feature from the CC, then, yes, I would agree, thereā€™s really no reason to continue to use the CC. Especially consideringā€¦

You can still have this feature by using my Composite Tracker CC ā€œon top ofā€ your Life360 trackers. (I do this.) But, of course, the downside would be loosing (direct) access to various attributes in the life360 device_tracker entities. They, of course, would still be there, only you couldnā€™t access them via the composite device_tracker entities. Does that make sense?

Regarding adding the time_as feature to the standard integration, I donā€™t want to go there. It seems too ā€œdiceyā€ for it to be accepted, and I want to stay on good terms. :slight_smile:

can confirm this to be as hoped for, zones are nicely displayed:

49

which leads to:

02

left = Home, middle = Zone Nmbs (showing correct overlay, life360 purple), right is Moving (life360 iconā€¦)

thanks Phil!

1 Like

Yes. I removed the folder, changed the configuration.yaml exactly as stated in the instructions and left the known devices with no changes. If I go to integrations, Life360 shows up there with (from configuration) at the end.

What did your life360 configuration look like when using the custom integration, and what does it look like now?

This is now:
life360:
  accounts:
    username: MYUSER
    password: MYPASS
  max_update_wait:
    minutes: 45

used to be:

device_tracker:
  - platform: life360
    username: MYUSER
    password: MYPASS
    max_update_wait:
      minutes: 30