Life360 Device Tracker Platform

I did the HA update before your last update.

>  - platform: life360
>    username: !secret life360_cam_username
>    password: !secret life360_cam_password
>    interval_seconds: 10
>    filename: life360.conf
>    max_update_wait:
>     minutes: 30

@claytonjn I did a copy and paste from this topic.

Just got it working added " show_as_state: places, driving, moving "

 - platform: life360
   username: !secret life360_cam_username
   password: !secret life360_cam_password
   interval_seconds: 10
   filename: life360.conf
   show_as_state: places, driving, moving
   max_update_wait:
    minutes: 30

source_type: gps
latitude: xxxx
longitude: xxxx
gps_accuracy: 65
battery: 74
last_update: 2018-05-17 19:17:58+01:00
at_loc_since: 2018-05-17 17:36:58+01:00
moving: false
charging: false
wifi_on: true
driving: false
friendly_name: Cameron

Thanks and sorry

Oh, ok. That shouldnā€™t have been necessary. If show_as_state is not specified, itā€™s supposed to default to none of those, which should be ok. I thought I tested that configuration, but I must have missed something. Iā€™ll check it out and let you know what I find.

1 Like

@cameron, well, I just tested with show_as_state removed from my configuration.yaml and it still works fine for me. :slightly_frowning_face: I even added a DEBUG statement to verify that it is indeed defaulting to an empty list in this case. So, I canā€™t explain why it wasnā€™t working for you. But Iā€™m glad itā€™s working now!

If it acts up anymore, please donā€™t hesitate to let me know. Iā€™ll also try 1) to update soon to the latest & greatest version of HA, and 2) get this code in github so itā€™s easier to use.

BTW, if it does every act up again, please make sure DEBUG messages are enabled in the log. E.g., (and for future reference) if you do:

head -n 5000 home-assistant.log | grep -v -e websocket -e group | grep -i life360

You should see at least the following if itā€™s working ok:

2018-05-17 13:30:52 INFO (MainThread) [homeassistant.loader] Loaded device_tracker.life360 from custom_components.device_tracker.life360
2018-05-17 13:30:52 INFO (MainThread) [homeassistant.components.device_tracker] Setting up device_tracker.life360
2018-05-17 13:30:53 DEBUG (Thread-21) [custom_components.device_tracker.life360] Life360 communication successful!
2018-05-17 13:31:04 DEBUG (Thread-8) [custom_components.device_tracker.life360] Checking members.
2018-05-17 13:31:04 DEBUG (Thread-8) [custom_components.device_tracker.life360] Updating member_name.

But as you can see, DEBUG needs to be enabled.

1 Like

So, since updating this component Iā€™m not longer getting status updates.
I only get changes for Home and Work (which are two locations setup in Life360). It seems to be ignoring my HA zones.

I no longer see the ā€˜movingā€™ status either.

I see this in my log.

AttributeError: module 'homeassistant.components.zone' has no attribute 'active_zone'; m = {'features': {'device': '1', 'smartphone': '1', 'nonSmartphoneLocating': '0', 'geofencing': '1', 'shareLocation': '1', 'shareOffTimestamp': None, 'disconnected': '0', 'pendingInvite': '0', 'mapDisplay': '1'}, 'issues': {'disconnected': '0', 'type': None, 'status': None, 'title': None, 'dialog': None, 'action': None, 'troubleshooting': '0'}, 'location': {'latitude': 'my_lat', 'longitude': 'my_long', 'accuracy': '50', 'startTimestamp': 1526594986, 'endTimestamp': '1526594986', 'since': 1526594986, 'timestamp': '1526594986', 'name': None, 'placeType': None, 'source': None, 'sourceId': None, 'address1': None, 'address2': '', 'shortAddress': '', 'inTransit': '1', 'tripId': None, 'driveSDKStatus': None, 'battery': '90', 'charge': '0', 'wifiState': '1', 'speed': 9.11, 'isDriving': '0'}, 'communications': [{'channel': 'Voice', 'value': 'my_phone', 'type': 'Home'}, {'channel': 'Email', 'value': 'my_email', 'type': None}], 'medical': None, 'relation': None, 'createdAt': '1525880983', 'activity': None, 'id': '02489e79-28c3-4587-96f0-bf7b64fb2421', 'firstName': 'my_FirstNAme', 'lastName': '', 'loginEmail': 'email@address', 'loginPhone': 'my_phone_number', 'avatar': 'my_avatar', 'isAdmin': '1', 'pinNumber': None}

Hmm, interesting. What version of HA are you on? I wonder if they made a change to the zone component. My platform only tries to call that function ā€“ zone.active_zone() ā€“ if it doesnā€™t get a Place name from Life360.

Iā€™m on 0.69.1 - latest.

Thanks.

Yep, just checked - they reorganized the zone component after 0.67.1 (which is what Iā€™m using.) Iā€™ll make a change later than can deal with both scenarios, but for now, can you try changing:

from homeassistant.components import zone

to

from homeassistant.components.zone import zone

This is in custom_components/device_tracker/life360.py. Let me know if that works for you.

@cameron & @claytonjn, this explains what we were discussing earlier. You might want to make this change, too. As soon as someone can verify this works, Iā€™ll go ahead and update with a slightly more robust change that should work with 0.67 & 0.69 (which Iā€™ve already written and tested with 0.67.1.)

@pnbruckner I can confirm that this works now with the change to homeassistant.components.zone.

My device tracker is back to showing the moving state as well as HA zones.

Thanks for testing it. And Iā€™m glad itā€™s working again. Iā€™ll post the fix that works with both versions soon.

1 Like

Platform broke (sometime) after HA version 0.67.1 due to zone component implementation being reorganized.

Fixed and tested with both 0.67.1 and 0.69.1.

Just a quick ā€œhelloā€ to all and a GREAT JOB to @pnbruckner.

I love the work you have done here and wanted to say THANK YOU!!!

1 Like

Would it be possible to have items detected with your integration have an option to prepend an indicator to the device name?

My devices show up in known_devices.yaml as

me_:
hide_if_away: false
icon:
mac:
name: 'me ā€™
picture:
track: true

which makes the device name
device_tracker.me_

Iā€™d like an option to make it easier to call out from others in that file.
ie:

life360_me_:
hide_if_away: false
icon:
mac:
name: 'me ā€™
picture:
track: true

which would now make the name

device_tracker.life360_me_

thanks

Yes, that should be pretty easy to add. Right now it just uses <firstName>_<lastName> as reported by Life360. But I suppose if you had multiple Device Trackers for yourself, there could easily be a conflict in naming. Iā€™ll work on adding a new config item for a device ID prefix. Iā€™ll post back when I have that working. Given what else Iā€™m working on right now that probably wonā€™t be until next week though.

In the meantime, you could simply modify this statement in the _update_member function in custom_components/device_tracker/life360.py:

dev_id = util.slugify('_'.join([m['firstName'], m['lastName']])
                         .replace('-', '_'))

to

dev_id = util.slugify('life360_' + '_'.join([m['firstName'], m['lastName']])
                                      .replace('-', '_'))
2 Likes

Tested and worked.

thanks.

1 Like

Moved code to github. Added optional prefix configuration parameter as discussed above.

HI Everyone,

I have installed this component, and it seems to work, based on my log files. Here is a snippet:

2018-05-29 21:06:28 DEBUG (SyncWorker_16) [custom_components.device_tracker.life360] Life360 communication successful!
2018-05-29 21:07:05 DEBUG (SyncWorker_0) [custom_components.device_tracker.life360] Checking members.
2018-05-29 21:07:06 DEBUG (SyncWorker_0) [custom_components.device_tracker.life360] Updating john_.
2018-05-29 21:07:06 DEBUG (SyncWorker_0) [custom_components.device_tracker.life360] Updating yolanda_.

However, what I find strange is that the device trackers are not showing up at all on my ā€˜Statesā€™ page. The only device trackers are my old existing trackers, the new Life360 is not showing up at all. Running HA 0.70

Any ideas on what I might be doing wrong or what I might have missed?

Thanks in advance

John

@pnbruckner thanks for this great component!
Itā€™s working like a charm and also works great together with the proximity sensor.

1 Like

Well, Iā€™m still on 0.69.1 I suppose there could be something new in 0.70 that is causing problems.

Is it possible that thereā€™s a name conflict? E.g., the default entity_idā€™s (in your case) should be device_tracker.john_ and device_tracker.yolanda_. Were these entity_idā€™s already used by your existing trackers? If so, you might be able to use the prefix config parameter I recently added. E.g., if you add:

prefix: life360

Then the entity_idā€™s should change to device_tracker.life360_john_ and device_tracker.life360_yolanda_. If the problem is a name conflict this should solve it.

1 Like

Hi,

I have literally just found the issue. It is related to the ā€˜track_new_devices: Falseā€™ which was set on my Owntracks tracker in device_tracker.yaml. I needed to set this to True, and now the trackers appear in the ā€˜Statesā€™ page.

Thank you for taking the time to respond.

John

1 Like