Life360 Device Tracker Platform

Hi,

Great work on this. much better than Owntracks. just a question, how do i pull the battery % out to display on the frontend. sorry for the stupid question, but still new.

Use a Template Sensor.

sensor:
  - platform: template
    sensors:
      dev_battery:
        friendly_name: My Device Battery
        value_template: "{{ state_attr('device_tracker.ME', 'battery') }}"
        unit_of_measurement: '%'
        device_class: battery

Hi, thanks for the brilliant platform! when installing iā€™m getting this error

SyntaxError: invalid syntax
Fatal error while loading config: invalid syntax (life360.py, line 7)
Failed config
  General Errors: 
- invalid syntax (life360.py, line 7)
Successful config (partial)

Thank you

My guess is you didnā€™t copy the file correctly from the github page. If you havenā€™t done this before, make sure you click the ā€œRawā€ button to get the raw text of the file. Iā€™m guessing you copied the HTML page source instead.

1 Like

Hi

Thank you so much. Work 100%.

Thank you that was the issue. I had initially right clicked the files and saved them to the directory but saving as raw worked!

Released 2.2.0

Low level communications module (i.e., custom_components/life360.py) moved to the official Python Package Index (PyPI.)

If youā€™ve already been using this custom component, after upgrading, you can remove custom_components/life360.py. If you havenā€™t used this custom component before, then installation is a bit simpler than before (since there is now only one file to install ā€“ specifically, custom_components/device_tracker/life360.py.)

@DrZzs, I had been planning to move the one file to PyPI for a while. If I had known you were creating that excellent video, I would have expedited the move. (I hadnā€™t ever published to PyPI before, so I had to get through those details.) :blush:

If anyone runs into any trouble using this new version (and indirectly the module from PyPI), by all means, let me know ASAP!

1 Like

Hi @pnbruckner thanks for the great work. I knew about your component in @DrZzs 's video.

Just a question, I followed his video before I found this thread, so I put life360.py also outside device_tracker folder. It seems everything is working, but should I remove that file and keep just the ā€œdevice_trackerā€ one? Many thanks!

HI @pnbruckner - thanks for the work and dedication with this project!

Iā€™ve just tried the new install - installed the life360 communications component from PyPI with a
sudo -H pip install "life360"
Then added the device_tracker section to my configuration.yaml file, but when I check the config in the web ui, I get " Configuration invalid Platform not found: device_tracker.life360" - my device tracker section looks like this:

device_tracker
  - platform: life360
    username: valid username
    password: valid password
    prefix: life360
    show_as_state: driving, moving, places
    driving_speed: 20
    max_gps_accuracy: 200
    max_update_wait:
      minutes: 30

Any ideas on what I might try?

There used to be two different files named life360.py, one that went in custom_components, and the other went in custom_components/device_tracker. Now thereā€™s only the one that goes in custom_components/device_tracker. You no longer need the one that went directly in custom_components, so you can delete it (although leaving it there wonā€™t hurt anything.)

1 Like

You do not need to manually install the package from PyPI. Home Assistant will take care of that automatically. And, FWIW, as I understand it, you should never install with pip using sudo. You may want to run the same command (stop HomeAssistant first), the same way (i.e., with sudo), but change install to uninstall.

Next you need to install my life360.py custom platform (from my github repo) into your HA config folder (in additional folders inside the config folder that you will probably have to manually create, namely custom_components/device_tracker) per the instructions on my github page. Then when you start Home Assistant it should work. Although, I generally recommend using the Custom Updater custom component rather than manually installing my custom component. Once you get Custom Updater installed and working, you can use it to install my custom component. Again, see my github repo for instructions.

Iā€™m getting this error:

ā€œget_circles: ReadTimeout: HTTPSConnectionPool(host=ā€˜api.life360.comā€™, port=443): Read timed out. (read timeout=11.0)ā€

Any tip?

Comm errors are not uncommon. If you get a zillion of them, and the device_trackers arenā€™t updating, then you might have a problem. Even when there are a lot of comm errors, usually itā€™s working just fine between the errors. If there are too many errors in a row, then youā€™ll see this: Suppressing further errors until OK: .... If youā€™re not seeing that, then it is working between the other errors.

Hi, im using your component and its working very well but i have 2 thing I wonder. The post is so long that i donā€™t know if it was anwered already.

First, when i look at my tracker info, i see that the ā€œaddressā€ is null even if it shows correctly on life360 app.
Second the data for ā€œat loc sinceā€ and ā€œlast seenā€ on the tracker are not following my timezone, can we change that ? It shows as ā€”> 2018-11-23T15:45:35+00:100:

Thank you in advance.

Hi, i donā€™t know if this is mentioned already but other people in my circle donā€™t show up if there away from home ? there only showing up when there home otherwise the dissapear.

******* problem Dissapeared??? ******

This is part Home Assistantā€™s generic device tracker behavior. Mainly itā€™s for device tracker implementations that can only show ā€œhomeā€ and ā€œnot homeā€ like various wifi device trackers. Youā€™ll need to edit your known_devices.yaml file to change that.

1 Like

Thanks Phil, Iā€™ve uninstalled the life360 comms component per your instruction - I already had (but neglected to mention that in my previous post) the life360.ph within the custom_components/device_tracker directory in place.

I am still getting the ā€œConfiguration invalid, Platform not found: device_tracker.life360ā€ message when I check the config in the HA UI.

Trying to install this and following the instructions in the post #333 above by @stratplayer.

Iā€™ve installed the custom_updater.py in the custom_components directory, added the config for custom_updater per philā€™s github repo, restarted HA and the custom_updater.install service is then available in the drop down.

Then I run that service with service data = {ā€œelementā€:ā€œlife360ā€} then run the same with {ā€œelementā€:ā€œdevice_tracker.life360ā€}

I get the following errors in the log:

2018-11-25 15:41:58 ERROR (MainThread) [homeassistant.core] Error executing service <ServiceCall custom_updater.install (c:f51af2dc5e404ce6b2a1a481a5c03d1e): element=life360>
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/core.py", line 1185, in _event_to_service_call
    await self._hass.async_add_executor_job(execute_service)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/core.py", line 1182, in execute_service
    service_handler.func(service_call)
  File "/config/custom_components/custom_updater.py", line 104, in install_service
    card_controller.install(element)
NameError: free variable 'card_controller' referenced before assignment in enclosing scope
2018-11-25 15:42:23 ERROR (MainThread) [homeassistant.core] Error executing service <ServiceCall custom_updater.install (c:32a496bdb58f4b588c12bf82fe6e25dc): element=device_tracker.life360>
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/core.py", line 1185, in _event_to_service_call
    await self._hass.async_add_executor_job(execute_service)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/core.py", line 1182, in execute_service
    service_handler.func(service_call)
  File "/config/custom_components/custom_updater.py", line 104, in install_service
    card_controller.install(element)
NameError: free variable 'card_controller' referenced before assignment in enclosing scope

What am I missing?

First, those instructions are old (believe it or not! :slight_smile:) The first ā€œelementā€ (life360) does not need to be installed manually/directly. You just need to install element device_tracker.life360. The other part should be installed automatically from the PyPI by HA when you restart (or I think the custom updater will do install it prior to restarting HA. Either way you shouldnā€™t have to.)

Next, that error is an issue with the custom updater. You should go to its issues page for help with that.

Unfortunately it can only show what the Life360 server provides. If address is null itā€™s because the server isnā€™t providing an address.

Like most components in HA, datetimes are shown in UTC. But, as long as they are timezone ā€œawareā€ datetimes, it really shouldnā€™t matter which timezone they are shown in. I suppose I could add an optional feature to show datetimes in the local timezone. See issue #69.