@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:
- My password had a special character in it that was forcing an escape in the script. Fixed that.
- 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 thenbrew 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
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.
Looks like the API has changed
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.
@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.
Yes, It is working for me - sort of. It looks like they had a crappy release last night, and I don’t think the API was changed as the component still works, except it goes offline more frequently. I would give it some time may be today or tomorrow just to make sure they stabilize their release.
I also noticed significant lag in loading the data when using their app. I suspect something changed at their end, may be they are getting ready for the new iOS release, or just regular feature updates.
That was my thought as well. I notice my daughter’s location reporting is a bit wonky in the iOS app and like I said I can’t log into their normal website UI with any of the accounts I have.
I will wait a bit but I think I need to consider a backup location/presence method just in case this happens again.
I was able to login to the web ui just fine. Everyone showing up as expected.