Life 360 support

@anon35356645 I have 4 brothers and all there kids, plus my mother all in different states (US)
Life360 it is the most accurate from our experience.
also we get alerts when someone leaves or arrives somewhere, This comes in handy especially with my mother if she arrives at the hospital we all get an alert.

Yes, please let us know if you make it work. I’ll keep my fingers crossed, and get back to you if I think of something.

@Aephir I haven’t had a chance to do a fresh install yet but was just thinking, I already have Owntracks working could that somehow be why I’m getting the Error.

Thanks

I don’t think so, I am running both, and get updates from both. As I understood it, both are publishing to the “owntracks” topic, but if you have different names in owntracks vs life360, then they’d be published to different subtopics, e.g. “owntracks/yourlife360name/yourlife360device” or “owntracks/owntracksID/owntracksDevice” or something like that.

The topic is defined in one of the last lines in the script, I suppose you could just change that if you’d prefer, but I think it was just easier since homeassistant is already set up to use “owntracks”.

Full disclosure, I know next to nothing about this, I’m just persistent, and google a lot :slight_smile: But it looked to me like it was complaining about the part with authentication?

You have a space or some character in front of “function”. Try this:
Shell into your raspberrypi and run:

cd ~/
wget https://raw.githubusercontent.com/Aephir/homeassistant/master/shell_scripts/life360.sh -O 360_mqtt_broker
nano 360_mqtt_broker # change the top 10 lines to your info and save changes
chmod +x 360_mqtt_broker
./360_mqtt_broker

This will print a log to the console and will quit when you exit the shell session.
To run in the background use:
nohup ~/360_mqtt_broker >/dev/null 2>&1 &

1 Like

@brazen1445 @Aephir OK Looks like I got the script to run. It listed all the user names so I believe its working OK.

I don’t have time to test everything, As I leave for a vacation in the morning, but when I get a chance to test it all I’ll let you all know Thanks for all your help.

1 Like

Good to hear!

@Aephir OK back from Vacation started checking, All seems to work great. I’m having a little trouble with battery sensors, I have a sensor.yaml file tried adding to that but they would not list in Current entities, So I had to add to my configuration.yaml to get it to report battery levels.

Also is there a way to send requests more often I see its about 5 minutes.

Thanks for the help

I had some trouble with the battery, but that seems to be unrelated to yours?

I needed to add (I have a bunch of sensor files added in sensor directory, included with sensor: !include_dir_merge_list sensor/

- platform: mqtt
  state_topic: "owntracks/Walden/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
  name: "My Phone Battery 360"
  unit_of_measurement: "%"
  value_template: "{{ value_json.batt }}"

Where the XXX… is my device ID. For some reason I needed dashes for the battery status, but not for the location tracking.

For the time, one of the first lines in the script says timeout=300. That means (as far as I can tell), that it updates every 300 seconds = 5 minutes. So change as needed.

@Aephir Well after working with it all day I did the same as you[quote=“Aephir, post:50, topic:1690”]
I needed to add (I have a bunch of sensor files added in sensor directory, included with sensor: !include_dir_merge_list sensor/

  • platform: mqtt
    state_topic: “owntracks/Walden/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX”
    name: “My Phone Battery 360”
    unit_of_measurement: “%”
    value_template: “{{ value_json.batt }}”
    [/quote]

I added a battery.yaml and all is fine now

Thanks for all your help

Glad it worked. But you should probably thank @brazen1445 instead of me; I just copied him :slight_smile:

Right, Also If anyone else runs into this i found you shouldn’t add the Mac address its not reliable

Thanks @brazen1445 for your help everything is working great

Hey, guys, I am fairly new to HA got most things running great and I know enough Linux to get by but this one is over my head.

I have my Life360 account setup and running on my iPhone along with CloudMQTT.

Here are some of my questions:

  1. You run the script on any Linux box and make sure mosquitto_pub is installed.

I am on a pi with Hassbian I believe that mosquito is installed as part of the AIO and I installed jq already.
What location should this file be created in, such as the home directory or homeassistant directory?
What do I save the file as I noticed a lot of people calling it life360.sh or do I just run it and background it?

  1. I have this setup as a
    device_tracker:
  • platform: owntracks

and I use Cloud MQTT so I have

mqtt:
broker: m13.cloudmqtt.com
port: 10704
client_id: life_360
keepalive: 60
username: xxxxxx
password: xxxxxx

But I do not see this come up in my known devices yaml.

I see this as my mosquitto_pub path according to Cloud MQTT /var/lib/mosquitto/10704/mosquitto.conf Is this correct?

  1. Are the sensors a necessary part to make this run or are they just used to get info?

Thanks in advance for the info sorry for all the questions but I cant fully peice this all together.

@enigmacarpc I run the script as a service in the background. Maybe a stupid question, but you did remember to edit the life360.sh file first, right? Editing the first 10 lines as described above?

Try using this guide for testing MQTT. Then run the script, and see if you get the info showing up on your command line. For instance, I run

mosquitto_sub -h 127.0.0.1 -v -t "owntracks/#"

Before running the script (as a service, but it shouldn’t matter for testing). Then I see my MQTT notifications being published the the “owntracks” topic (and sub-topics). Something like:

owntracks/aephir/phone {"_type":"location","tid":"s7","acc":16,"batt":76,"conn":"m","lat":REDACTED,"lon":REDACTED,"tst":REDACTED}
owntracks/REDACTED/REDACTED {"t":"p","tst":REDACTED,"acc":50,"_type":"location","alt":0,"lon":REDACTED,"lat":REDACTED,"batt": 77}

Where the top is my owntracks (actually owntracks) and the bottom is from the life360. Let me know if this works.

@Aephir I haven’t run the script yet I was confused as to where if needed the script was to be placed but you are saying to just run it and background it.

Also, I am using cloud MQTT not a local MQTT server I am not sure where to point the mosquitto_pub line to point to.

Thanks for the info I’m still not 100% but will run the script and test.

Update: ran mosquitto_sub -h 127.0.0.1 -v -t “owntracks/#” got bash mosquitto sub not found.

Installed mosquitto locally and fixed that issue.

Now when I run the command I get bash: /etc/mosquitto/mosquitto.conf: Permission denied.

The script does see my Life360 info as far as the users I have setup I see them listed before the permission issue.

So my 2 current issues are 1. how to fix the permission issue and 2 how to use this with a cloud MQTT.

I can’t be of much help with a cloud MQTT. Maybe you can just change the info in the top 10 lines? Or maybe it needs a local MQTT broker running? I actually don’t know.

I missed that you were using cloud when suggesting the mosquitto test. If it can be used, you could probably do the same with cloud? Test what is published to “owntracks” topics when running the life360 script?

If you want to use mosquitto, the /etc/mosquitto/mosquitto.conf (and /etc/mosquitto/conf.d/) are not scripts, they are configuration files. You need to edit them, so e.g.

sudo nano /etc/mosquitto/mosquitto.conf

I had some issues with setting up mosquitto, and ended up having to do a clean install of Debian. But I got a lot of help, and the method outlined in this thread worked for me. One of the users there posted config files as well, so you can use those as guidelines.

@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.