Skip to content

Commit

Permalink
Composite: Adjust to changes in HA 0.94
Browse files Browse the repository at this point in the history
  • Loading branch information
pnbruckner committed Jun 6, 2019
1 parent 730b3c4 commit e4ec399
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
4 changes: 2 additions & 2 deletions custom_components.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
]
},
"device_tracker.composite": {
"updated_at": "2019-04-22",
"version": "1.7.4",
"updated_at": "2019-06-06",
"version": "1.7.5",
"local_location": "/custom_components/composite/__init__.py",
"remote_location": "https://raw.githubusercontent.com/pnbruckner/homeassistant-config/master/custom_components/composite/__init__.py",
"visit_repo": "https://github.com/pnbruckner/homeassistant-config",
Expand Down
2 changes: 1 addition & 1 deletion custom_components/composite/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Composite Device Tracker."""

__version__ = '1.7.4'
__version__ = '1.7.5'
20 changes: 16 additions & 4 deletions custom_components/composite/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,26 @@

from homeassistant.components.binary_sensor import DOMAIN as BS_DOMAIN
from homeassistant.components.device_tracker import (
ATTR_BATTERY, ATTR_SOURCE_TYPE, ENTITY_ID_FORMAT, PLATFORM_SCHEMA,
ATTR_BATTERY, ATTR_SOURCE_TYPE, PLATFORM_SCHEMA,
SOURCE_TYPE_BLUETOOTH, SOURCE_TYPE_BLUETOOTH_LE, SOURCE_TYPE_GPS,
SOURCE_TYPE_ROUTER)
try:
from homeassistant.components.device_tracker.const import ENTITY_ID_FORMAT
except ImportError:
from homeassistant.components.device_tracker import ENTITY_ID_FORMAT
from homeassistant.components.zone import ENTITY_ID_HOME
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_BATTERY_LEVEL,
ATTR_ENTITY_ID, ATTR_GPS_ACCURACY, ATTR_LATITUDE, ATTR_LONGITUDE,
ATTR_STATE, CONF_ENTITY_ID, CONF_NAME, EVENT_HOMEASSISTANT_START,
STATE_HOME, STATE_NOT_HOME, STATE_ON, STATE_UNKNOWN)
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.event import track_state_change
from homeassistant.util.async_ import run_callback_threadsafe
import homeassistant.util.dt as dt_util

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -221,8 +229,10 @@ def _update_info(self, entity_id, old_state, new_state, init=False):
cur_lon = cur_state.attributes[ATTR_LONGITUDE]
cur_acc = cur_state.attributes[ATTR_GPS_ACCURACY]
cur_gps_is_home = (
active_zone(self._hass, cur_lat, cur_lon, cur_acc)
.entity_id == ENTITY_ID_HOME)
run_callback_threadsafe(
self._hass.loop, async_active_zone, self._hass,
cur_lat, cur_lon, cur_acc
).result().entity_id == ENTITY_ID_HOME)
except (AttributeError, KeyError):
cur_gps_is_home = False

Expand Down Expand Up @@ -256,6 +266,8 @@ def _update_info(self, entity_id, old_state, new_state, init=False):
init)
return

_LOGGER.debug('Updating %s from %s', self._entity_id, entity_id)

tz = None
if self._time_as in [TZ_DEVICE_UTC, TZ_DEVICE_LOCAL]:
tzname = None
Expand Down
1 change: 1 addition & 0 deletions docs/composite.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,4 @@ Date | Version | Notes
20190419 | [1.7.2](https://github.com/pnbruckner/homeassistant-config/blob/6da2f09b5cf49db3b02403958e41763231c0a7ec/custom_components/composite) | ... and apparently custom_updater needs an `__init__.py` file, too.
20190419 | [1.7.3](https://github.com/pnbruckner/homeassistant-config/blob/7be70ac6f3445a755c4f3060bfc00cc3019a33b3/custom_components/composite) | ... and older HA versions still need REQUIREMENTS & DEPENDENCIES!
20190422 | [1.7.4](https://github.com/pnbruckner/homeassistant-config/blob/e8e87ca3019ed98cb54f119032266fd72e86b3be/custom_components/composite) | ... and they need to be in the right place!!
20190606 | [1.7.5]() | Adjust to changes in HA 0.94.

0 comments on commit e4ec399

Please sign in to comment.