Skip to content

Commit

Permalink
Life360: Adjust to changes in the upcoming 0.94 release (#148)
Browse files Browse the repository at this point in the history
Items imported from device_tracker and zone have changed. Adjust accordingly, while maintaining backwards compatibility.
  • Loading branch information
pnbruckner committed May 31, 2019
1 parent f47fd15 commit ac37bbf
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
4 changes: 2 additions & 2 deletions custom_components.json
Expand Up @@ -27,8 +27,8 @@
]
},
"device_tracker.life360": {
"updated_at": "2019-05-03",
"version": "2.10.0",
"updated_at": "2019-05-31",
"version": "2.10.1",
"local_location": "/custom_components/life360/__init__.py",
"remote_location": "https://raw.githubusercontent.com/pnbruckner/homeassistant-config/master/custom_components/life360/__init__.py",
"visit_repo": "https://github.com/pnbruckner/homeassistant-config",
Expand Down
2 changes: 1 addition & 1 deletion custom_components/life360/__init__.py
@@ -1,3 +1,3 @@
"""Life360 Device Tracker."""

__version__ = '2.10.0'
__version__ = '2.10.1'
33 changes: 23 additions & 10 deletions custom_components/life360/device_tracker.py
Expand Up @@ -9,12 +9,21 @@
import voluptuous as vol

from homeassistant.components.device_tracker import (
CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL, DOMAIN,
ENTITY_ID_FORMAT as DT_ENTITY_ID_FORMAT, PLATFORM_SCHEMA)
CONF_SCAN_INTERVAL, DOMAIN, PLATFORM_SCHEMA)
try:
from homeassistant.components.device_tracker.const import (
ENTITY_ID_FORMAT as DT_ENTITY_ID_FORMAT,
SCAN_INTERVAL as DEFAULT_SCAN_INTERVAL)
except ImportError:
from homeassistant.components.device_tracker import (
DEFAULT_SCAN_INTERVAL, ENTITY_ID_FORMAT as DT_ENTITY_ID_FORMAT)
from homeassistant.components.zone import (
DEFAULT_PASSIVE, ENTITY_ID_FORMAT as ZN_ENTITY_ID_FORMAT, ENTITY_ID_HOME,
Zone)
from homeassistant.components.zone.zone import active_zone
try:
from homeassistant.components.zone import async_active_zone
except ImportError:
from homeassistant.components.zone.zone import async_active_zone
from homeassistant.const import (
ATTR_BATTERY_CHARGING, ATTR_FRIENDLY_NAME, ATTR_LATITUDE, ATTR_LONGITUDE,
ATTR_NAME, CONF_FILENAME, CONF_PASSWORD, CONF_PREFIX, CONF_USERNAME,
Expand All @@ -24,7 +33,8 @@
from homeassistant.helpers.entity import generate_entity_id
from homeassistant.helpers.event import track_time_interval
from homeassistant.util import slugify
from homeassistant.util.async_ import run_coroutine_threadsafe
from homeassistant.util.async_ import (
run_callback_threadsafe, run_coroutine_threadsafe)
from homeassistant.util.distance import convert
import homeassistant.util.dt as dt_util

Expand Down Expand Up @@ -517,12 +527,15 @@ def _update_member(self, member, dev_id):
# If we don't have a location name yet and user wants driving or
# moving to be shown as state, and current location is not in a HA
# zone, then update location name accordingly.
if not loc_name and not active_zone(
self._hass, lat, lon, gps_accuracy):
if SHOW_DRIVING in self._show_as_state and driving is True:
loc_name = SHOW_DRIVING.capitalize()
elif SHOW_MOVING in self._show_as_state and moving is True:
loc_name = SHOW_MOVING.capitalize()
if not loc_name:
active_zone = run_callback_threadsafe(
self._hass.loop, async_active_zone, self._hass, lat, lon,
gps_accuracy).result()
if not active_zone:
if SHOW_DRIVING in self._show_as_state and driving is True:
loc_name = SHOW_DRIVING.capitalize()
elif SHOW_MOVING in self._show_as_state and moving is True:
loc_name = SHOW_MOVING.capitalize()

try:
battery = int(float(loc.get('battery')))
Expand Down
1 change: 1 addition & 0 deletions docs/life360.md
Expand Up @@ -223,3 +223,4 @@ Date | Version | Notes
20190422 | [2.9.4](https://github.com/pnbruckner/homeassistant-config/blob/e8e87ca3019ed98cb54f119032266fd72e86b3be/custom_components/life360) | ... and they need to be in the right place!!
20190423 | [2.9.5](https://github.com/pnbruckner/homeassistant-config/blob/e10832d66e36cd691a7c40770d733ae73dc29af0/custom_components/life360) | Fix flake8 & pylint errors and move some error checking to custom configuration validators.
20190503 | [2.10.0](https://github.com/pnbruckner/homeassistant-config/blob/b0a9a8f4a317f300c3075f8a393e6119d4527e46/custom_components/life360) | Add debug output showing dev_id's (i.e., the second part of the device_tracker entity_id's) that will be included if `members` is used. Also, the first time data for each member is retrieved from the server, output the full name of the member, the corresponding dev_id, and whether or not that member will be tracked.
20190531 | [2.10.1]() | Adjust to changes in HA 0.94.

0 comments on commit ac37bbf

Please sign in to comment.