diff --git a/homeassistant/components/automation/zone.py b/homeassistant/components/automation/zone.py index 553d59b7da1..f62aec8bf2a 100644 --- a/homeassistant/components/automation/zone.py +++ b/homeassistant/components/automation/zone.py @@ -36,17 +36,13 @@ def trigger(hass, config, action): def zone_automation_listener(entity, from_s, to_s): """ Listens for state changes and calls action. """ if from_s and None in (from_s.attributes.get(ATTR_LATITUDE), - from_s.attributes.get(ATTR_LONGITUDE)): + from_s.attributes.get(ATTR_LONGITUDE)) or \ + None in (to_s.attributes.get(ATTR_LATITUDE), + to_s.attributes.get(ATTR_LONGITUDE)): return - if None in (to_s.attributes.get(ATTR_LATITUDE), - to_s.attributes.get(ATTR_LONGITUDE)): - return - - from_zone = _in_zone(hass, from_s) if from_s else None - to_zone = _in_zone(hass, to_s) - from_match = from_zone and from_zone.entity_id == zone_entity_id - to_match = to_zone and to_zone.entity_id == zone_entity_id + from_match = _in_zone(hass, zone_entity_id, from_s) if from_s else None + to_match = _in_zone(hass, zone_entity_id, to_s) if event == EVENT_ENTER and not from_match and to_match or \ event == EVENT_LEAVE and from_match and not to_match: @@ -71,22 +67,19 @@ def if_action(hass, config): def if_in_zone(): """ Test if condition. """ - state = hass.states.get(entity_id) - - if not state or None in (state.attributes.get(ATTR_LATITUDE), - state.attributes.get(ATTR_LONGITUDE)): - return - - cur_zone = _in_zone(hass, state) - - return cur_zone and cur_zone.entity_id == zone_entity_id + return _in_zone(hass, zone_entity_id, hass.states.get(entity_id)) return if_in_zone -def _in_zone(hass, state): +def _in_zone(hass, zone_entity_id, state): """ Check if state is in zone. """ - return zone.in_zone( - hass, state.attributes.get(ATTR_LATITUDE), + if not state or None in (state.attributes.get(ATTR_LATITUDE), + state.attributes.get(ATTR_LONGITUDE)): + return False + + zone_state = hass.states.get(zone_entity_id) + return zone_state and zone.in_zone( + zone_state, state.attributes.get(ATTR_LATITUDE), state.attributes.get(ATTR_LONGITUDE), state.attributes.get(ATTR_GPS_ACCURACY, 0)) diff --git a/homeassistant/components/device_tracker/__init__.py b/homeassistant/components/device_tracker/__init__.py index 31729b5d4a6..c4f57601272 100644 --- a/homeassistant/components/device_tracker/__init__.py +++ b/homeassistant/components/device_tracker/__init__.py @@ -364,7 +364,8 @@ class Device(Entity): elif self.location_name: self._state = self.location_name elif self.gps is not None: - zone_state = zone.in_zone(self.hass, self.gps[0], self.gps[1]) + zone_state = zone.active_zone(self.hass, self.gps[0], self.gps[1], + self.gps_accuracy) if zone_state is None: self._state = STATE_NOT_HOME elif zone_state.entity_id == zone.ENTITY_ID_HOME: diff --git a/homeassistant/components/frontend/version.py b/homeassistant/components/frontend/version.py index fbdfad56a65..abf0c498b1a 100644 --- a/homeassistant/components/frontend/version.py +++ b/homeassistant/components/frontend/version.py @@ -1,2 +1,2 @@ """ DO NOT MODIFY. Auto-generated by build_frontend script """ -VERSION = "8d460d7298e41397b4f94ef103b2a067" +VERSION = "c4722afa376379bc4457d54bb9a38cee" diff --git a/homeassistant/components/frontend/www_static/frontend.html b/homeassistant/components/frontend/www_static/frontend.html index f88bd7884da..73fdb905114 100644 --- a/homeassistant/components/frontend/www_static/frontend.html +++ b/homeassistant/components/frontend/www_static/frontend.html @@ -5636,7 +5636,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN } iron-image { border-radius: 50%; - }