From dee92445669e98006b84f715b9af63dc55f424c8 Mon Sep 17 00:00:00 2001 From: Brent Date: Tue, 19 Jul 2016 21:51:14 -0500 Subject: [PATCH] Move location lookup before zone checks. (#2557) --- homeassistant/components/sensor/google_travel_time.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/sensor/google_travel_time.py b/homeassistant/components/sensor/google_travel_time.py index 4add83a87b..be42ddf838 100644 --- a/homeassistant/components/sensor/google_travel_time.py +++ b/homeassistant/components/sensor/google_travel_time.py @@ -244,6 +244,10 @@ class GoogleTravelTimeSensor(Entity): self.valid_api_connection = False return None + # Check if the entity has location attributes + if location.has_location(entity): + return self._get_location_from_attributes(entity) + # Check if device is in a zone zone_entity = self._hass.states.get("zone.%s" % entity.state) if location.has_location(zone_entity): @@ -257,10 +261,6 @@ class GoogleTravelTimeSensor(Entity): if entity_id.startswith("sensor."): return entity.state - # For everything else look for location attributes - if location.has_location(entity): - return self._get_location_from_attributes(entity) - # When everything fails just return nothing return None