Life 360 support

As far as reliable background location updating goes with iOS, Life 360 has been the most reliable client I’ve used with Smart Things (It blows owntracks out of the water on reliability). It would be fantastic if someone could write a component for Hass. In the mean time I’m tempted to try and adjust the Smartthings mqtt code to pass on the life 360 location and battery info.

No need to edit anything. See my reply to your post on the Smartthings message board. :slight_smile: It’s as simple as adding the Presence Sensor in the Bridge smartapp.

I would be interested in this… @atomicpapa can you provide more details. Thanks!

Life360 connects to Smartthings via a Smartapp, Smartthings connects to HASS via the ST-MQTT Bridge which is a combination of Smartapp on the ST server and a bridge app on your own server.

So that would require SmartThings? If it can connect to ST, it should be possible to interface with HA.

Exactly. The bridge allows you to pass anything connected to ST over to HASS via MQTT

The only problem is the Life360 app for smart things keeps the lat/long/ and battery info internal and only passes present and not present through the MQTT bridge. https://community.smartthings.com/t/current-mobile-location-lat-lon/37775/10

Is the app working only with smart things hub?

Was taking a look at this- life 360 is most accurate across both phone platforms.

Can someone help out converting this to python

First you need to get the bearer access token via this call

https://api.life360.com/v3/oauth2/authorize?client_id=pREqugabRetre4EstetherufrePumamExucrEHuc&response_type=token&redirect_uri=http%3A%2F%2Fhome-assistant.io

using this bearer id you can get the following

Circles
curl -X GET -H “Authorization: Bearer XXXX bearer code from above call XXX” https://api.life360.com/v3/circles.json

From Circles you can use the circle id to get

Places

curl -X GET -H “Authorization: Bearer XXXX bearer code from above call XXX” https://api.life360.com/v3/circles/XXX Circle id XXXX/places.json

and Members
curl -X GET -H “Authorization: Bearer XXXX bearer code from above call XXX” https://api.life360.com/v3/circles/XXX Circle id XXXX/members.json

Which reveals their lat long and batt etc in JSON. which is what we need

There is a web hook setting to trigger when a change of a member happens but still trying to figure how use that
https://api.life360.com/v3/circles/${state.circle}/webhook.json

2 Likes

Wow…this is perfect. I did not even know that there was an API available. I’m hoping someone can help us integrate Life360 in HA.

Adding a Me Too for this feature request please.

Thanks.

Me 3 :wink:

Thanks

This feature would be a great addition. I currently use Life360 in combination with IFTTT. It would be great to bring it all into Home Assistant.

1 Like

Would love to have this as well!!

1 Like

I wrote a quick shell script to login to life360 and publish a mqtt message. It’s pretty basic but seems to work well. Just fill in your username and password in the script and run it. You also need to add the following to your configuration.yaml:
"device_tracker:

  • platform: owntracks"

You can find the script at https://pastebin.com/3q3ntT0a

2 Likes

Wow…this is exciting. How do we run the script? Can you provide little more details and steps involved? Also, if I already have a MQTT server (mosquitto), can I just use that? IN which case, what should mosquitto_pub="/path/to/mosquitto_pub" be?

I’ve been using life 360 for a long time and got tired of checking for the promised api. If the app is now useable that would be awesome. I have found it to be a reliable app. I tried it with IFTTT and getting a response 15-30 minutes later was pointless. This is encouraging news!

You can run the script on any linux box. Make sure you have jq and mosquitto_pub installed. mosquitto_pub is part of the mosquitto package, so if you have mosquitto installed mosquitto_pub should already be on your server.
Create a new file on your linux server. paste the code from the pastebin into it. Change the top ten lines to your personal information. Chmod +x the file and run it. It requests member locations every 300 sec (set by the timeout var) it then publishes a JSON message (in the owntracks format) to owntracks/FirstName/DeviceID/ on the mqtt server you specified.
Use nohup to run the script in the background when your done testing.

I am just starting to evaluate home assistant to run for my home automation. I did not want to invest to much time into this. I don’t sanitize any input from life360, so don’t name your kids Tommy’); DROP TABLE or anything silly. Also, life360 does not publish any info about their api so they might block this at some point.

I copied the code to file life360.sh, modified the first few lines, and have both jq and mosquitto_pub installed. I ran the script and get the following errors:

pi@raspberrypi:/home/hass/.homeassistant/python $ ./life360.sh
./life360.sh: line 4: username360: command not found
./life360.sh: line 5: password360: command not found
Error: Unknown option '='.

Use 'mosquitto_pub --help' to see usage.
./life360.sh: line 7: mqtt_host: command not found
./life360.sh: line 8: mqtt_port: command not found
./life360.sh: line 9: mqtt_user: command not found
./life360.sh: line 10: mqtt_pass: command not found
timeout: invalid time interval ‘=’
Try 'timeout --help' for more information.
./life360.sh: line 21: syntax error near unexpected token `<'
./life360.sh: line 21: `    read - a circles_id << <$(curl - s - X GET - H "Authorization: Bearer $1" https: // api.life360.com / v3 / circles.json | grep - Po '(?<="id":")[\w-]*')'

change first line to #!/bin/sh