Life360 Device Tracker Platform

I will update and try this weekend

1 Like

It seemed to work for me, no errors in the log. I updated the main file and the device tracker file, I saw commits to both. I added add_zones:true and an interval of 60.

All my zones showed up. The all have the same icon, and when you click them you donā€™t get anything, anyway to show a label or something so you know what the area is?

Iā€™m thinking I will disable make automations now to have Home Assistant alert when at an area instead of Life360 then all my notifications come from one place.

Not sure how to make that automation, but sure itā€™s a standard zone thing somewhere in HA I just havenā€™t looked up yet.

Awesome work!

1 Like

I see this page, so I assume you copied the name?

Where in HA can you list all your zones? You can see icons and circles on a map, but they are not entities, so you donā€™t know their names.

Iā€™m not 100% sure Iā€™m following you.

The zone (friendly) names in HA should be the same as the Place names in Life360. When viewed on the map you should be seeing these names. The entity_idā€™s come from an algorithm in HA, but basically if all the Place names are unique, then the corresponding zone entity_idā€™s should be the Place name changed to all lower case, with spaces replaced by underscores, parentheses removed, etc. There are a few other possible transformations, but thatā€™s the basic idea. So a Place name of ā€œMy Workā€ should create a zone entity_id of zone.my_work. You can see all the entity_idā€™s on the States page in the frontend.

For automations, you have two choices. You can use a zone trigger, or you can use device_tracker states, because when a device_tracker is in a zone, the device_trackerā€™s state is set to the (friendly) name of the zone. So, e.g., letā€™s say you had a Life360 Place named ā€œMy Workā€, which creates a zone entity_id of zone.my_work, you could trigger when device_tracker.me enters that zone either of these ways:

trigger:
  platform: zone
  entity_id: device_tracker.me
  zone: zone.my_work
  event: enter

or

trigger:
  platform: state
  entity_id: device_tracker.me
  to: 'My Work'

Just remember for the latter, when a device_tracker is in the Home zone its state is ā€˜homeā€™, not ā€˜Homeā€™.

Go it, see all the zones in the entities list now. My map for some reason has no text, just icons, wonder if thatā€™s something I need to turn on somewhere?

Hmm, interesting. When I tested this feature I was focusing on whether or not the zones showed up on the map and if they were the right size (i.e., did I get the units correct - meters vs feet.) I also saw the icon, which I chose to look like the same icon Life360 uses. But now that you mention it I canā€™t say for sure whether or not the names appeared on the map. (I know zones defined in HAā€™s config show the names on the map.) Iā€™ll have to test again to see.

Well, just checked the zone doc page, and it says this for icon:

The icon to show instead of name.

Hmm, maybe I should nix the icon. :slight_smile:

I think home icon is obvious, for others, maybe no icon so we see the text

I tried to make one automation to cover everything, but it randomly goes off even when the state doesnā€™t change. I assume some other value of the state is changing? it will just say Iā€™m home every few minutes over and over, any ideas?

  • id: zone_change
    alias: Zone Change
    trigger:
    platform: state
    entity_id: device_tracker.phone1, device_tracker.phone2
    action:
    • service: notify.notify
      data_template:
      message: ā€œ{{ trigger.to_state.name }} has arrived at {{ trigger.to_state.state }}ā€

You should format your YAML code using the instructions at the top of the page to make it readable.

But, yes, a state trigger without to or from will trigger for any state change, including only changes to attributes. And GPS-based device_trackers like Life360 will definitely update many times while the actual state string does not change.

You can add a condition that only lets the action run if the actual state string changed. I donā€™t have time right now, but Iā€™ll edit this response in a while to show how you might do thatā€¦

EDIT: Try this:

- id: zone_change
  alias: Zone Change
    trigger:
    platform: state
    entity_id: device_tracker.phone1, device_tracker.phone2
  condition:
    condition: template
    value_template: >
      {{ trigger.to_state and trigger.from_state and
         trigger.to_state.state != trigger.from_state.state and
         trigger.to_state != 'not_home' }}
  action:
    service: notify.notify
    data_template:
      message: "{{ trigger.to_state.name }} has arrived at {{ trigger.to_state.state }}"

This will only notify if the state string changes, and it doesnā€™t change to ā€˜not_homeā€™ (aka Away.)

I just tried it without an icon and sure enough now the name shows up on the map.

One interesting result I noticed while testing. So as not to bother the members in my usual Circle, I created a temporary circle so I could add Places to it. What I realized is, Places from all circles will be added as zones in HA. So whereas in Life360 Places are unique to circles, in HA youā€™ll see all Places from all circles. I donā€™t think thatā€™s an issue, but something to consider. If this becomes a problem I suppose I could add another option to specify which circle or circles from which to use Places.

Anyway, Iā€™ll be checking in 2.0.0b3 soon, and before long releasing 2.0.0.

Released 2.0.0 (& library 1.1.0.)

Add option to create HA zones from Life360 Places. Add optional config variables add_zones and zone_interval. If add_zones is true or zone_interval is defined, create zones at startup. If zone_interval is defined update zones periodically. Do not use Life360 Places named Home (case insensitive.)

1 Like

I updated and the names showed up, so it worked! Also, thanks for the automation, I added tonight and its not going crazy, so we will see how it works moving around tomorrow.

1 Like

This platform has been reporting the deviceā€™s charging status in an attribute named ā€˜chargingā€™. However, it appears ā€˜battery_chargingā€™ is more common. To be more consistent with other platforms, Iā€™m going to change the attribute from ā€˜chargingā€™ to ā€˜battery_chargingā€™. Obviously this is a breaking change.

See issue #61 (and somewhat related issue #60.)

Iā€™m willing to be convinced to leave it the way it is, though. :wink: If you feel strongly either way, please comment in my github issue #61, or here if you canā€™t use github.

1 Like

Released 2.1.0 ā€“ BREAKING CHANGE

Change charging attribute to the more common battery_charging attribute. Instead of a float, make battery attribute an int like it should have been originally.

getting: ERROR (MainThread) [homeassistant.bootstrap] Error loading /config/configuration.yaml: mapping values are not allowed here

Any ideas?

device_tracker:
  - platform: life360
    username: !secret life360_username
    password: !secret life360_password
    interval_seconds: 10
    filename: life360.conf
    show_as_state: places, driving, moving
    max_update_wait:
      minutes: 30

How did you add Life360 into the custom tracker? Iā€™ve just installed the customer tracker and am not sure what to do next, Iā€™ve forgotten how I added stuff into before I had to rebuild from scratch.

Must be something basic in your configuration file(s), because I donā€™t see anything wrong with that snippet. If youā€™d like to share more details via private message Iā€™d be happy to try and help further. Also, is there more to that error message? It usually will tell what file and give a line and column number, which can sometimes help narrow down where the problem is.

Have you seen these:

My Life360 doc
My installation doc
Custom Updater installation doc

Donā€™t forget my Life360 implementation consists of two custom components: life360 and device_tracker.life360. You need to make sure you install both.

2 Likes

Yes all sorted now!
Sorry was being an idiot. Iā€™d done this before is Lovelace but never in standard UI so was looking at my old config files wondering how it ever worked! Then I realised I needed to add the additional bits under custom_updater:

1 Like