Life360 Device Tracker Platform

yes, but i took it to be an issue with the card tracker. Had several card with an available update , clicked update all, and updating went one by one.

Hi,

this is a new error for me, probably since updating to .80.3 (maybe before, but never noticed)

2018-10-22 08:49:40 ERROR (SyncWorker_9) [custom_components.device_tracker.life360] get_circle "Family": HTTPError: 400 Client Error: Bad Request for url: https://api.life360.com/v3/circles/4c4-redacted

and

2018-10-22 09:13:57 ERROR (SyncWorker_19) [custom_components.device_tracker.life360] get_circles: HTTPError: 500 Server Error: Internal Server Error for url: https://api.life360.com/v3/circles.json

suppose it is a device_tracker issue, because I can login on the life360.com page and see my family without issue.

This seems to work great for me. I havenā€™t done any automations yet, still setting things up, but status seems to be updating accurately.

I notice on built in map it shows home, with the circle drawn on the location from life360, and I see the people move around the map correctly, and when they get to other locations we have set, the words update on the entity, but I donā€™t see other locations on the map, should I?

These are communication/server errors. They mean your HA instance was not able to communicate with the Life360 server, or the Life360 server was not able to process the request for some reason. They just happen from time to time. Nothing I can do about it, other than to filter them somehow and prevent you (the user) from seeing them. I did add some filtering when the same error happens continually so as not to flood the HA log. Other than that, Iā€™m not sure I should do any more. From what Iā€™ve seen, itā€™s common practice for component code to just output errors. FWIW, I see comm errors on other, completely unrelated devices, too, when, for example, my Internet connection drops out temporarily. Yes, they are annoying, but the only other option is to hide them and not know itā€™s happening. If you donā€™t like seeing them you could change the logging level for custom_components.device_tracker.life360 to fatal or critical.

The circle youā€™re seeing on the HA built-in map is a HA zone, which probably just so happens to coincide with your Life360 Place named Home. If youā€™d like other marked locations on the map then youā€™ll have to define additional HA zones.

So far, Life360 Places are only used to update the state of the device_tracker (if you have it configured that way.) I havenā€™t attempted to somehow automatically create/update HA zones based on Life360 Places. I really havenā€™t even thought of doing that. Hmm, maybe thatā€™s a feature I could look into adding. Not sure itā€™s even possible/practical, but Iā€™ll add it to my ā€œto doā€ list. :slight_smile:

In case it helpsā€¦ information created through the HA Integrations menu, including Zones, are written to config/.storage/core.config_entries in what looks like JSON format.

1 Like

Released 1.6.1 BREAKING CHANGE

Event names were too long, causing errors with some databases. Shorten the event names (i.e., event_type) by removing device_tracker. prefixes.

Does the Life360 app behave differently in power saving mode? Battery is at 17%, went home at 12:40 and only at 13:06 did life360 wake up to the change in state. How best would I work around this? Iā€™m really missing bluetooth tracking but I sadly canā€™t do bluetooth due to my home 2.4Ghz environment :frowning:
Itā€™s weird because yesterday life360 tracking was working really well, but today it just seems to have nosedived - I wonder if itā€™s because of the low battery on my phone.
I do have door sensors so I guess I could look into somehow triggering a refresh based on a door being opened?
EDIT: Just been reading this thread. Looks like triggering a force refresh either isnā€™t possible due to it being an undocumented API thatā€™s been reverse engineered or plain old isnā€™t exposed in the API.

Your question, of course, should probably be directed to Life360 Support, since it has more to do with how the Life360 app and server work than how my code interacts with the Life360 server. But I can tell you from personal experience that, yes, power saving modes on the phone do seem to affect itā€™s update rates. E.g., I almost never put my phone into power saving mode, whereas my wife almost always has her phone in power saving mode. Not surprisingly, my updates are pretty responsive, whereas my wifeā€™s updates arenā€™t. We both have Samsung Galaxy S7 Android phones. My daughter, on the other hand, has an iPhone and her updates are sometimes hit or miss, most of the time being pretty responsive, but sometimes, especially when not on WiFi, having some long update times.

What Iā€™ve found works pretty well for my wife and I is using three different device trackers per phone: Life360, Google Maps Location Sharing, and ping. Believe it or not, on the same phone, sometimes Life360 updates really well and Google doesnā€™t, and sometimes itā€™s the opposite, although most of the time they both update pretty well, at least for me. For my wife with her phone in power saving mode, both Life360 and Google tend to have significant drop-outs from time to time, but luckily, they donā€™t seem to happen at the same time. Yes, I know, weird! So using both seems, for the most part, to fill in the gaps to get pretty responsive updates, even for my wifeā€™s phone in power saving mode. (And since we were already using both services, using them both with HA doesnā€™t seem to have any effect on overall battery usage.) Lastly, I use ping which sometimes helps cause quicker transitions to home, but not often, especially for my wife since Android seems to not respond to pings hardly at all in power saving mode.

And the way I use all three trackers per device is through my custom Composite Device Tracker Platform. :slight_smile:

2 Likes

What phone do you have? On newer versions of Android you can allow specific apps to bypass battery optimization. This would improve responsiveness (even in battery save mode, I believe) but would obviously decrease battery life of the device.

Thanks - an iPhone - so sadly not an option!

Thanks - will give some/all of this a shot! :slight_smile: Appreciate your lengthy and considered reply.

FWIW, I found every option I could (and Iā€™m pretty sure I drilled down into every menu on the phone!) to allow Life360 to run as often as it wants, yet when power saving mode is on, it still has lengthy update intervals sometimes, which does not happen (or at least nearly as much) when power saving mode is off. Canā€™t guarantee I found and tried everything, but I did give it the old college try. :slight_smile:

same experience here:
Ive been home for 9 minutes already and Life360 still shows me moving :slightly_smiling_face:

20

If I may post here, my most reliable trackers are the composites, indeed as @pnbruckner says. The CC Composite is pretty accurate, and notices me home so correctly I have my outside lights react to it welcoming me home in the evening.
Also, a hand made Mqtt tracker is really very adequate, I set that up with help from @NotoriousBDG and looks like this:

##########################################################################################
## Device_trackers
##########################################################################################
# https://www.home-assistant.io/components/device_tracker.mqtt_json/
# https://community.home-assistant.io/t/double-trigger-home-not-home/58912/66
device_tracker:
  - platform: mqtt_json
    devices:
      m_presence: location/m  

and automations:

  - alias: M Presence Update from GPS
    trigger:
      platform: state
      entity_id:
     # - device_tracker.telefoon #disabled iCloud because of battery drain
        - device_tracker.owntracks #very accurate
        - device_tracker.life360_m
        - device_tracker.homeassistant_app
    action:
      service: mqtt.publish
      data_template:
        topic: "location/m"
        retain: true
        payload: >-
          {
            "latitude": "{{ trigger.to_state.attributes.latitude }}",
            "longitude": "{{ trigger.to_state.attributes.longitude }}",
            "battery_level": {{ trigger.to_state.attributes.battery | int }} ,
            "gps_accuracy": {{ trigger.to_state.attributes.gps_accuracy | int }}
          }
# https://community.home-assistant.io/t/double-trigger-home-not-home/58912/11

  - alias: M Presence Update from Router or Bluetooth
    trigger:
      platform: state
      entity_id:
        - device_tracker.ping_telefoon
        - device_tracker.telefoon_m_bt
        - device_tracker.m # regular wifi
      to: home
    action:
      service: mqtt.publish
      data_template:
        topic: "location/m"
        retain: true
        payload: >-
          {
            "latitude": "{{ states.zone.home.attributes.latitude }}",
            "longitude": "{{ states.zone.home.attributes.longitude }}",
            "battery_level": {{state_attr('device_tracker.life360_m','battery')|int}},
            "gps_accuracy": 0
          }

Hope this inspires new ways, glad to share

Power-save turns off the GPS receiver, so when Life360 calls on it, the GPS has to reacquire the satellites.

1 Like

That would be awesome if you could make it read the locations in Life360 and automatically add zones in HA, would keep it all in sync. I can do them all by hand, but would be cool feature.

So, as Iā€™ve mentioned, the Life360 API Iā€™m using isnā€™t officially supported or documented (as far as Iā€™ve been able to discover.) But using Postman I took a wild guess and discovered I can actually retrieve defined Places for a given Circle! For each Place it provides the name, itā€™s GPS coordinates and radius. That should be enough to define HA Zones.

The question then becomes, when to get this information from Life360 and use it to define corresponding Zones in HA. Iā€™ll have to give that some thought, but at least, it does look like the information is available. :slight_smile:

If you have any thoughts, or would just like to follow my progress on this topic, check out my related github issue.

Awesome! I will follow up on Git

Created a beta release that adds HA zones that correspond to Life360 defined Places (except for any Place named any form of the word ā€˜homeā€™.) This happens at startup, and then every 15 minutes. During the updates if any Places have been deleted then the corresponding HA zones will be removed, and if any Places have been newly defined then corresponding HA zones will be added. I will probably make this an optional feature, but for now it always does this.

If anyone is interested in trying it out, or commenting in any way about this new feature, please see Pull Request #59 in my github repo. If you do want to try it, both parts (custom_components/life360.py and custom_components/device_tracker/life360.py) have been updated so donā€™t forget to get both.

Updated beta release (to 2.0.0b2) to add config options:

add_zones ā€“ Type: boolean. If true then create HA zones from Life360 Places. Default is false if zone_interval is not specified, true if it is.
zone_interval ā€“ Type: time period; minimum: one minute. If specified Places will be checked periodically and HA zones will be updated accordingly. If not specified, and add_zones is true, then only check Places and create HA zones at startup.

I still need to update the documentation, but if anyone gives it a try Iā€™d like to hear how it works for you.