Life360 Device Tracker Platform

Just follow the installation instructions.

So. All seems to have gone well. Hassio is all back and working with life360 not complaining at all.

However:
I installed the
custom_updater so next time I can just use the ā€œcustom_updater.update_allā€ service.

But a word of caution to othersā€¦ it too is a custom component and as such may lead to issues. as of right now itā€™s still supported and will track updates of other custom components for you and allow you to use the service ā€œcustom_updater.update_allā€

Now I have this error.
19-05-02 16:47:28 ERROR (MainThread) [hassio.api.proxy] Client error on WebSocket API Cannot connect to host 172.30.32.1:8123 ssl:False [Connection refused].

Iā€™m not sure where in my system I need to set ssl to ā€œtrueā€?

So this feature (being able to list a subset of members to include) has been around since July 2018 (and this custom component has only itself been around a little longer than that.) So itā€™s pretty much always been there.

I did find the post where the feature was requested. It has to do with Life360 Members who often turn off their phones, and donā€™t need to be tracked anyway. Without being able to exclude them, it causes a lot of errors in the log. I suppose that could be addressed another way, but why ping the Life360 server unnecessarily? Every member has to be updated via a separate query to the server, so trying to get updates for Members that arenā€™t being tracked anyway would cause a lot of unnecessary traffic.

So I think Iā€™ll leave the feature in, with some enhancements Iā€™ve already made to hopefully make it easier to use. Iā€™ll also try to do a better job of making it more obvious in the documentation not to use this feature unless you need to. (E.g., I wonā€™t put it in the ā€œfullā€ example, because people tend to just copy those examples without thinking too much about it. :stuck_out_tongue_winking_eye:)

EDIT:

FWIW, this is what the config variable will look like:

members:
  include:
    - Joe Smith
    - Jane Smith
    - Child1

or

members:
  exclude:
    - Mr Spock
    - Bones

Letā€™s say you have two Circles, where Joe Smith, Jane Smith and Child1 are in a Circle named ā€œMy Familyā€, and Mr Spock and Bones are in another Circle named ā€œStar Trekā€. Without specifying the members config variable, all would be tracked. However, with either of the configuration options above, only Joe Smith, Jane Smith and Child1 would be tracked.

Youā€™d see something like this with the first option (and with DEBUG enabled):

DATE TIME DEBUG (SyncWorker_4) [homeassistant.components.life360.device_tracker] Including: life360_joe_smith, life360_jane_smith, life360_child1

Or with the second option:

DATE TIME DEBUG (SyncWorker_4) [homeassistant.components.life360.device_tracker] Excluding: life360_mr_spock, life360_bones

Followed by (in either case):

DATE TIME DEBUG (SyncWorker_4) [homeassistant.components.life360.device_tracker] Joe Smith -> life360_joe_smith: will be tracked
DATE TIME DEBUG (SyncWorker_4) [homeassistant.components.life360.device_tracker] Updating life360_joe_smith
DATE TIME DEBUG (SyncWorker_4) [homeassistant.components.life360.device_tracker] Jane Smith -> life360_jane_smith: will be tracked
DATE TIME DEBUG (SyncWorker_4) [homeassistant.components.life360.device_tracker] Updating life360_jane_smith
DATE TIME DEBUG (SyncWorker_4) [homeassistant.components.life360.device_tracker] Child1 -> life360_child1: will be tracked
DATE TIME DEBUG (SyncWorker_4) [homeassistant.components.life360.device_tracker] Updating life360_child1
DATE TIME DEBUG (SyncWorker_4) [homeassistant.components.life360.device_tracker] Mr Spock -> life360_mr_spock: will NOT be tracked
DATE TIME DEBUG (SyncWorker_4) [homeassistant.components.life360.device_tracker] Bones -> life360_bones: will NOT be tracked
DATE TIME DEBUG (SyncWorker_4) [homeassistant.components.life360.device_tracker] Setup successful!

After that youā€™ll just see the usual ā€œUpdating ā€¦ā€ messages.

Iā€™m also going to add a circles configuration variable, which can also have include or exclude. So the same result could be obtained by:

circles:
  include:
    - My Family

Or:

circles:
  exclude:
    - Star Trek

circles and members can be used together or separately. This is similar to how the recorder can be configured (except in its case itā€™s domains and entity_ids.)

EDIT 2:

BTW, the nice thing about this DEBUG output is, if youā€™re not sure what the full names are in Life360, you can leave the members variable out at first, and just look at the debug output to see what they are. Then you can copy and paste into the members config variable as needed. (And then remove corresponding entries in know_devices.yaml.)

@Lima I see you just liked a post where the suggestion was to delete the life360.conf file. Since release 2.9.0 (made on 3/21/2019) that should no longer be necessary. If you change your Life360 password, and update your HA life360 configuration accordingly, the life360.conf file should be automatically deleted and regenerated with the new credentials. Just an FYI! :slight_smile:

1 Like

If thatā€™s the case then Iā€™d agree with leaving it. In my quick look over the code it looked like line 544 gets data for all members in the given circle and then you loop through those results, only updating the HA entities that were included in configuration.

It doesnā€™t matter to me either way, just trying to save you unnecessary work.

Great component @pnbruckner
Iā€™ve been using it for quite some time without issue. I recently updated HASS to 92.1 and it unfortunately broke my Life360 integration. Iā€™ve tried following your instructions and am trying to manually install 2.9.5 without luck. I figured I would simply delete the old files in the folder and start over, but wonder if that screwed things up. Hereā€™s the error:

Error setting up platform life360
Traceback (most recent call last):
File ā€œ/config/custom_components/life360/device_tracker.pyā€, line 149, in setup_scanner
from life360 import life360, LoginError
ModuleNotFoundError: No module named ā€˜life360ā€™

I believe this is because Iā€™m not using the custom updater and need to install the life360 package (pip install life360) but Iā€™m feeling helpless as I canā€™t figure out where/how to do that. Iā€™m not using the custom updater as it seemed easy enough to copy the contents of the raw files and put them in the custom_components/life360 folder.

I didnā€™t see this error posted yet, so Iā€™m sure itā€™s something Iā€™m doing wrong.

Thanks in advance!!!

Duh! Yeah, youā€™re right! :blush: I guess itā€™s been a while since I concentrated on that particular detail. Yes, it does get data for all the members in a particular Circle in one query. IIRC from when I did mess with those details I could have it get individual member data one at a time, but that would probably make it worse in the general case.

Still thereā€™s the error case that started it all, and the feature has been there so long ā€¦ I might regret it, but Iā€™ll leave the feature in for now.

Youā€™re right, you donā€™t need custom_updater. HA itself should install the package. (Generally, unless you really know what youā€™re doing, you donā€™t want to mess with that.)

Are you sure you have all three files?

/config/custom_components/life360/device_tracker.py
/config/custom_components/life360/__init__.py
/config/custom_components/life360/manifest.json

And that you copied them from github using the Raw button for each?

I am absolutely positive I have all 3 files and that they were copied from the RAW format. It also automatically created a __pycache__ folder that has 2 files:

/config/custom_components/life360/__pycache__/__init__.cpython-37.pyc
/config/custom_components/life360/__pycache__/device_tracker.cpython-37.pyc

Here is the full error:

Fri May 03 2019 06:55:23 GMT-0400 (Eastern Daylight Time)
Error setting up platform life360
Traceback (most recent call last):
  File "/config/custom_components/life360/device_tracker.py", line 149, in setup_scanner
    from life360 import life360, LoginError
ModuleNotFoundError: No module named 'life360'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/device_tracker/__init__.py", line 177, in async_setup_platform
    disc_info)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/life360/device_tracker.py", line 154, in setup_scanner
    except LoginError as exc:
UnboundLocalError: local variable 'LoginError' referenced before assignment

The only thing I can think of is HA is having problems installing the life360 package. Here is what I see in my log (after doing a fresh install of 0.92.2):

(ha-0.92.2) phil@ha-intel:~/test/ha-0.92.2$ grep -e Attempting -e life360 ~/.homeassistant/home-assistant.log
2019-05-03 08:03:27 INFO (SyncWorker_1) [homeassistant.util.package] Attempting install of aiohttp_cors==0.7.0
2019-05-03 08:03:28 INFO (SyncWorker_7) [homeassistant.util.package] Attempting install of sqlalchemy==1.3.0
2019-05-03 08:03:30 INFO (SyncWorker_9) [homeassistant.loader] Loaded life360 from custom_components.life360
2019-05-03 08:03:30 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for life360 which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2019-05-03 08:03:30 INFO (SyncWorker_10) [homeassistant.util.package] Attempting install of restrictedpython==4.0b8
2019-05-03 08:03:31 INFO (SyncWorker_2) [homeassistant.util.package] Attempting install of pychromecast==3.2.1
2019-05-03 08:03:33 INFO (SyncWorker_1) [homeassistant.util.package] Attempting install of life360==3.0.0
2019-05-03 08:03:34 INFO (SyncWorker_11) [homeassistant.util.package] Attempting install of timezonefinderL==2.0.1
2019-05-03 08:03:38 INFO (MainThread) [homeassistant.components.device_tracker] Setting up device_tracker.life360
2019-05-03 08:03:38 INFO (SyncWorker_19) [homeassistant.util.package] Attempting install of home-assistant-frontend==20190427.0
2019-05-03 08:03:38 DEBUG (SyncWorker_8) [custom_components.life360.device_tracker] Updating life360_xxx
2019-05-03 08:03:38 DEBUG (SyncWorker_8) [custom_components.life360.device_tracker] Updating life360_yyy
2019-05-03 08:03:38 DEBUG (SyncWorker_8) [custom_components.life360.device_tracker] Updating life360_zzz
2019-05-03 08:03:38 DEBUG (SyncWorker_8) [custom_components.life360.device_tracker] Setup successful!

Can you show me a complete, recursive directory listing for /config/custom_components?

With HA stopped, do you know how to use pip to list installed packages in the environment in which HA runs?

Oddly enough, thereā€™s not a single entry in my log file that contains ā€œAttemptingā€ - so itā€™s clearly not attempting to install anything. I did have this working at one time with an earlier version of HA, but thought Iā€™d clear stuff out and use the 3 new files after updating to 0.92.1

Seriously thoughā€¦ if this isnā€™t an issue that others are experiencing, I can simply backup my configs and do a fresh install of HA tonight.
image

Iā€™ve never used PIP to list installed packages, but Iā€™m happy to try it. I have SSH access, but the PIP command doesnā€™t seem to be installed.

1 Like

Thatā€™s not necessarily an issue. If the packages required are already installed (from a previous run), it doesnā€™t need to install them, and hence you wouldnā€™t see those messages. But, in your case, it doesnā€™t seem to be able to find the life360 pypi.org package, so thatā€™s a problem.

Ok, so thatā€™s all the files under /config/custom_components (i.e., you didnā€™t just show a truncated output)? If so, then it doesnā€™t look like a file from an older version (e.g., /config/custom_components/life360.py, or /config/custom_components/device_tracker/life360.py) is causing a problem.

Iā€™ve only used a ā€œvenvā€ install, so Iā€™m not sure what youā€™d need to do to get ā€œintoā€ the Python environment used by HA in your scenario (again, since I assume youā€™re using hassio, or something like that.) So, unfortunately, if you donā€™t already know how to do that, Iā€™m not going to be able to help. You may need to do a fresh install and then the first time you run it, see if it attempts to install ā€œlife360==3.0.0ā€, and ultimately, if the error goes away.

So a couple of interesting details (that may or may not mean anything):

Here is a listing from my test system:

(ha-0.92.2) phil@ha-intel:~/.homeassistant/custom_components$ ls -lR
.:
total 4
drwxrwxr-x 3 phil phil 4096 May  3 09:05 life360

./life360:
total 36
-rw-rw-r-- 1 phil phil 22196 May  3 09:05 device_tracker.py
-rw-rw-r-- 1 phil phil    53 May  3 09:05 __init__.py
-rw-rw-r-- 1 phil phil   301 May  3 09:05 manifest.json
drwxrwxr-x 2 phil phil  4096 May  3 09:06 __pycache__

./life360/__pycache__:
total 20
-rw-rw-r-- 1 phil phil 14929 May  3 09:06 device_tracker.cpython-36.pyc
-rw-rw-r-- 1 phil phil   207 May  3 09:06 __init__.cpython-36.pyc

First, notice that the file sizes of the three files in the life360 folder differ from what you get. Look in __init__.py ā€“ what version do you have?

Also, notice the file extensions of the files in __pycache__. You must be using Python 3.7, whereas Iā€™m using 3.6. That shouldnā€™t matter, butā€¦ :man_shrugging:

Released 2.10.0

Added debug output showing dev_idā€™s (i.e., second part of device_tracker entity_idā€™s) that will be included if members configuration variable is used. Also, the first time data for each member is retrieved from the Life360 server, output a debug message that shows the memberā€™s full name (which is what needs to be used in the members configuration variable, if you choose to use it ā€“ it is optional after all :wink:), the corresponding dev_id, and whether or not the member will be tracked.

If you use members, then you should see output like this:

2019-05-03 09:26:57 DEBUG (SyncWorker_14) [custom_components.life360.device_tracker] Including: life360_aaa_bbb, life360_ccc

Whether or not you use members, you should always see output like this:

2019-05-03 09:26:57 DEBUG (SyncWorker_14) [custom_components.life360.device_tracker] Aaa Bbb -> life360_aaa_bbb: will be tracked
2019-05-03 09:26:57 DEBUG (SyncWorker_14) [custom_components.life360.device_tracker] Updating life360_aaa_bbb
2019-05-03 09:26:57 DEBUG (SyncWorker_14) [custom_components.life360.device_tracker] Ccc -> life360_ccc: will be tracked
2019-05-03 09:26:57 DEBUG (SyncWorker_14) [custom_components.life360.device_tracker] Updating life360_ccc
2019-05-03 09:26:57 DEBUG (SyncWorker_14) [custom_components.life360.device_tracker] Ddd Bbb -> life360_ddd_bbb: will NOT be tracked
2019-05-03 09:26:57 DEBUG (SyncWorker_14) [custom_components.life360.device_tracker] Setup successful!

If everything seemed to install ok, and you get no configuration errors (other than the usual warning about using a custom integration), yet you donā€™t see the device_tracker entities you expect, or theyā€™re not updating, and youā€™re using the members configuration variable, then make sure debug is enabled in the logger, and look in home-assistant.log for messages like the above. Especially look at the full names shown for each member, and compare that to what youā€™re using in the members configuration variable.

Iā€™ve made the PR a ā€œWIPā€ (Work-In-Progress) for now.

I just updated it with the latest changes relative the members configuration variable, as well as adding a new circles configuration variable. The idea is, if you donā€™t use these, all members from all circles will be tracked, which, I would think, would be the ā€œnormalā€ case for most people.

However, you can use them to limit which members are tracked. First you can specify which circles to include or exclude. Second you can specify which members to include or exclude (from the set of members that are in the circles that are included, or not excluded.) This is similar to how the recorder component is configured (except with domains and entity_idā€™s.) To be clear, you can use circles, or members, or both.

Anyway, if anyone would like to take a look and provide feedback, and maybe even try it out as it is now, Iā€™d appreciate it! If you do try it, note that youā€™ll need to adjust you configuration accordingly. On that note, I still have to update the proposed documentationā€¦

Lastly, I plan to add one more configuration variable: places, which will also be an exclude or include list type of variable. This will impact show_as_state: places and add_zones (and be ignored if neither of those are used.) Again, the idea is being able to limit which Places are used in case there are some you donā€™t care to see in HA (or if there are only a few you do. And, now that I think of it, add_zones can be simplified, since places can be used to include or exclude the ā€œHome Placeā€ when it comes to updating ā€“ or not updating ā€“ zone.home.)

iā€™ve got a problem , iā€™m always appear home and my battery is still 100% and always battery chargingā€¦

i try the debug but all seems ok

019-05-03 19:56:12 DEBUG (SyncWorker_17) [custom_components.life360.device_tracker] Fabrice Barthelemy -> life360_fabrice_barthelemy: will be tracked 2019-05-03 19:56:12 DEBUG (SyncWorker_17) [custom_components.life360.device_tracker] Updating life360_fabrice_barthelemy 2019-05-03 19:56:12 DEBUG (SyncWorker_17) [custom_components.life360.device_tracker] Setup successful!

Youā€™re a bit vague, but Iā€™m guessing you mean that when youā€™re phone is not home device_tracker.life360_fabrice_barthelemy still shows as home. What does it show on the Life360 app or website? If the Life360 server doesnā€™t know the phone is away from your home, thereā€™s no way for HA to know it.

Regarding the battery and charging state, itā€™s possible the battery level is rounded to 100% even though itā€™s still actually charging. But, again, if the Life360 server isnā€™t getting updates from your phone, thereā€™s no way for HA to get updates.

If the problem is indeed that Life360 isnā€™t getting updates from your phone, then Iā€™d suggest checking the Life360 FAQs.

1 Like

Yes you find it , i relaunch the android app and all the info are updated !!

1 Like

Hello all. I migrated to 0.92 and I had a problem with the component.
The solution was:

Open device_tracker.py and cut the 2 lines:
DEPENDENCIES = [ā€˜zoneā€™]
REQUIREMENTS = [ā€˜life360==2.*ā€™]

Create a file custom_components\life360_init_.py and paste there the 2 lines.
Thats it!

I hope it will help someone!