Move location lookup before zone checks. (#2557)

This commit is contained in:
Brent
2016-07-19 21:51:14 -05:00
committed by Paulus Schoutsen
parent a6e95db618
commit dee9244566

View File

@@ -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