Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions homeassistant/components/device_tracker/google_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

_LOGGER = logging.getLogger(__name__)

CONF_MAX_GPS_ACCURACY = 'max_gps_accuracy'
ATTR_ADDRESS = 'address'
ATTR_FULL_NAME = 'full_name'
ATTR_LAST_SEEN = 'last_seen'
Expand All @@ -31,6 +32,7 @@
MIN_TIME_BETWEEN_SCANS = timedelta(seconds=30)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_MAX_GPS_ACCURACY, default=100000): vol.Coerce(float),
vol.Required(CONF_USERNAME): cv.string,
vol.Required(CONF_PASSWORD): cv.string,
})
Expand All @@ -53,6 +55,7 @@ def __init__(self, hass, config: ConfigType, see) -> None:
self.see = see
self.username = config[CONF_USERNAME]
self.password = config[CONF_PASSWORD]
self.max_gps_accuracy = config[CONF_MAX_GPS_ACCURACY]

try:
self.service = Service(self.username, self.password,
Expand All @@ -76,6 +79,14 @@ def _update_info(self, now=None):
_LOGGER.warning("No location(s) shared with this account")
return

if self.max_gps_accuracy is not None and \
person.accuracy > self.max_gps_accuracy:
_LOGGER.info("Ignoring %s update because expected GPS "
"accuracy %s is not met: %s",
person.nickname, self.max_gps_accuracy,
person.accuracy)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add return here, then you do not need the else

Copy link
Copy Markdown
Contributor Author

@PrimusNZ PrimusNZ Aug 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is within a for loop (Looping thorough the tracked entities returned from Google)
Adding a return would abort the rest of the loop and entities would be missed - Have changed to a continue instead

continue

attrs = {
ATTR_ADDRESS: person.address,
ATTR_FULL_NAME: person.full_name,
Expand Down