Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Life360: Adjust to changes in the upcoming 0.94 release #148

Merged
merged 4 commits into from May 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.