Life 360 support

@Aephir I dont think you are understanding where I am at.

I have changed the first 10 lines and ran the command, the result was /etc/mosquitto/mosquitto.conf: Permission denied.

I have already edited the mosquitto.conf file with my info.

So I am looking into why when I paste your command string I get a permission issue on the mosquitto/mosquitto.conf

As for mosquitto itself, the MQTT works just fine as I have run some tests and gotten messages.

I would prefer to use Cloud MQTT but this seems to be an issue because your script needs to see a local mosquitto pub file, so I have put that all on hold.

Ahh, sorry, perhaps I was a bit tired when reading.

OK, what are your permissions for that file? Try these

ls -l /etc/mosquitto/

And see what it spits out for each. You should at the very least have read access to the user who will be running it. E.g. mine says:

ls -l /etc/mosquitto/
drwxr-xr-x 2 root root 4096 Jun  7 20:46 ca_certificates
drwxr-xr-x 2 root root 4096 Jun  7 20:46 certs
drwxr-xr-x 2 root root 4096 Jun  7 20:46 conf.d
-rw-r--r-- 1 root root  415 Apr 19 00:36 mosquitto.conf
drwxr-xr-x 7 pi   pi   4096 Apr 18 01:10 tools

So everyone can read the mosquitto.conf, even though it’s owned by “root”. If this is not the case, you can use

sudo chmod +r /etc/mosquitto/mosquitto.conf

which adds the “read” permission (for everyone! Change accordingly if that’s an issue for you) to that file. Hopefully I understood the problem this time :slight_smile:

Oh, and it’s not my script. All credit goes to brazen1445, I just used what he/she made. I have no clue at all about how to actually make that from scratch (and barely a clue to what most of it means/does).

Update: I figured out the issue with permissions my mosquitto_pub="/path/to/mosquitto_pub" was not set to the right path it was pointing to the mosquitto.conf file.

After running the command now it just sits there saying 1497556848 INFO: requesting members
“user name”
“user name”

No new device in the .yaml file

So I am not sure what is wrong now.

Sorry for all the posts but that’s how it goes in the world of the Homeassistant.

I was able to get everything working seemed to be an MQTT issue after fixing the above problems.

The issue seems to be with adding my own mosquitto install as the AIO for Hassbian did not install the service fully I ran an install of mosquitto again on top of what I had installed and I noticed that 2 strange devices were in my knowndevices.yaml and I knew it was working once I saw that.

It’s odd I am able to use 2 different logins and passwords as my first mosquitto install points to a password file with another password then what I setup in the new mosquitto install.

But so far this is the best presence sensor ever as I have been working with Trackr for a month and their app and system are garbage I wrote an article on another thread and basically the app was taking 3-5 hours to update locations and they fixed the issue after 10 support tickets but the Trackr app only updates your location in the app it doesnt send that info to home assistant for 30 minutes and sometimes you need to actually open the app and view the info for it to update.

@brazen1445 Thank you very much for the script! I was able to integrate it with no problems and have it running as a service via systemctl. Created all my zones in HA and am able to add Life360’s stable device tracking to my current presence detection. Really appreciate you putting it together.

Hey, maybe I should have posted in this thread first, but I wasn’t sure (I’m still not) if it’s specifically related to the script or not. But I’ve had issues after updating HASS. The location only works when I’m home, anywhere else it jumps between that location and “home”.

Has anyone seen anything like this? Or any ideas if I missed something important?

I noticed a few days ago it wasn’t working right, but today it has been fine, wife drove all over town today and it updated at every zone.
I haven’t updated to 47.0 yet still on 46.1

Is there an API call/day limit?

@brazen1445 Thanks so much for this script! Got it up and running in a matter of minutes on my local MQTT server.

@ntalekt Would be interested how you got this to run via systemctl.

Me and my family have been using this app for a while now and it’s great to have it working in Home Assistant, I was just about to set them all up with OwnTracks but it would have been a nightmare convincing them it was needed.

A question though, as it polls every 300 seconds. Will everyone in my circles notice a drop in battery life? I’m not sure how life360 works but won’t it keep polling their devices for a location update?

Anyone noticed battery life decrease?

Cheers!

Hopefully @brazen1445 or someone else might have a clue what’s up here as I am super excited to run this. I too hae found Life360 to be the best iOS based location app. I have been playing with Owntracks but I find it times out too easily and stops running, at least on iOS 11 Beta.

Anyway…

I have the script installed and upon running I get:

INFO: requesting access token
usage: grep [-abcDEFGHhIiJLlmnOoqRSsUVvwxZ] [-A num] [-B num] [-C[num]]
	[-e pattern] [-f file] [--binary-files=value] [--color=when]
	[--context[=num]] [--directories=action] [--label] [--line-buffered]
	[--null] [pattern] [file ...]
(23) Failed to writing body

INFO: requesting circles.
usage: grep [-abcDEFGHhIiJLlmnOoqRSsUVvwxZ] [-A num] [-B num] [-C[num]]
	[-e pattern] [-f file] [--binary-files=value] [--color=when]
	[--context[=num]] [--directories=action] [--label] [--line-buffered]
	[--null] [pattern] [file ...]
(23) Failed to writing body

and that repeats for as long as I run the script.

Any ideas?

Okay fixed my own issue by running the commands manually in a shell and fixing stuff step by step.

Two things I needed to fix:

  1. My password had a special character in it that was forcing an escape in the script. Fixed that.
  2. After soom Googling I found out that thre -P (Perl) flag has not been avialable in OSX since 10.8 so that is why the grep’s where failing. So two choices: Fix the grep (I am no grep-xpert) or just install the GNU version of grep. To do that for OSX: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" and then brew install grep --default-names (note the --with-default-names allow you to use GNU grep with the normal grep command. (this one maybe @brazen1445 can put this in host script comments or something)

After this my devices showed up in known_devices.yaml.

Hopefully this will help get people working on OSX if they have had issues. I also have this working with Opentracks and also have my bridge from Smartthings (https://home-assistant.io/blog/2016/02/09/Smarter-Smart-Things-with-MQTT-and-Home-Assistant/). My plan is to see if I can use the Life 360 sensor (which is only home/not home) via Smartthings for arrival scripts but then Life 360 for locating people in other zones outside the house. Only reason is I am not sure how low I can take the timeout of this script to trigger arrival home scripts where as the Life360/Smartthings integration is almost instance on arriving in the Life 360 home zone.

Script no longer seems to be gathering data from Life360. When I run a tail of nohup.out I get the following…

glenn@zeus:~$ tail nohup.out
1504615921 INFO: requesting access token
1504615921 INFO: requesting circles.
1504616221 INFO: requesting access token
1504616221 INFO: requesting circles.
1504616521 INFO: requesting access token
1504616521 INFO: requesting circles.
1504616821 INFO: requesting access token
1504616821 INFO: requesting circles.
1504617121 INFO: requesting access token
1504617121 INFO: requesting circles.
glenn@zeus:~$

Previously it would show a list of the people in my circle every time it would request data from the Life360 site. Anyone know what’s going on?

@brazen1445 I am still having the above error. Script was running fine for a long time but has just stopped for no apparent reason. Has Life360 changed something that prevents the script from logging in and getting the information?

I wrote a custom component in python for Life360 based on the shell script someone wrote. The python based custom component makes HTTP calls to the Life360, renders the data in OwnTracks format and drops it into the MQTT. I configured OwnTracks with my Home Assistant, and the device trackers are automatically updated.

Here is the Life360 custom component https://github.com/skalavala/smarthome/blob/master/custom_components/sensor/life360.py

Also check out the Life360.yaml from my repo at https://github.com/skalavala/smarthome/blob/master/packages/life360.yaml

4 Likes

Awesome!

Only issue I had was that grep in Hass.io doesn’t seem to support the -P flag for Perl regex, so the positive lookbehind isn’t supported. Easiest way I could come up with to fix that was to change lines 44 & 45 to:

COMMAND1 = "curl -s -X POST -H \"Authorization: Basic cFJFcXVnYWJSZXRyZTRFc3RldGhlcnVmcmVQdW1hbUV4dWNyRUh1YzptM2ZydXBSZXRSZXN3ZXJFQ2hBUHJFOTZxYWtFZHI0Vg==\" -F \"grant_type=password\" -F \"username=USERNAME360\" -F \"password=PASSWORD360\" https://api.life360.com/v3/oauth2/token.json | grep -o '\"access_token\":\"[^\"]*' | cut -c 17-"
COMMAND2 = "curl -s -X GET -H \"Authorization: Bearer ACCESS_TOKEN\" https://api.life360.com/v3/circles.json | grep -o '\"id\":\"[^\"]*' | cut -c 7-"

Not as elegant, but it’s working.

1 Like

I have the same issue now since last night. @brazen1445 any ideas?

Looks like the API has changed :frowning:

Yikes!. I wonder @skalavala’s new component is working? @claytonjn’s post is from yesterday and seems it’s working for him.

Oddly, I tried to login into https://www.life360.com/circles/#/ and I can’t login in with any of my accounts. I wonder if this is more of an outage situation vs API change.

@skalavala’s seems to still be working

@atomicpapa since you have a scipt that is working, can you see if you can login directly at https://www.life360.com/circles/#/ with your username and password? Curious if this is ‘locked accounts’ vs some change in the API.