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
16 changes: 13 additions & 3 deletions homeassistant/components/device_tracker/automatic.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@

DEFAULT_TIMEOUT = 5

SCOPE = ['location', 'vehicle:profile', 'trip']
DEFAULT_SCOPE = ['location', 'vehicle:profile', 'trip']
FULL_SCOPE = DEFAULT_SCOPE + ['current_location']

ATTR_FUEL_LEVEL = 'fuel_level'

Expand All @@ -58,8 +59,17 @@ def async_setup_scanner(hass, config, async_see, discovery_info=None):
client_session=async_get_clientsession(hass),
request_kwargs={'timeout': DEFAULT_TIMEOUT})
try:
session = yield from client.create_session_from_password(
SCOPE, config[CONF_USERNAME], config[CONF_PASSWORD])
try:
session = yield from client.create_session_from_password(
FULL_SCOPE, config[CONF_USERNAME], config[CONF_PASSWORD])
except aioautomatic.exceptions.ForbiddenError as exc:
if not str(exc).startswith("invalid_scope"):
raise exc
_LOGGER.info("Client not authorized for current_location scope. "
"location:updated events will not be received.")
session = yield from client.create_session_from_password(
DEFAULT_SCOPE, config[CONF_USERNAME], config[CONF_PASSWORD])

data = AutomaticData(
hass, client, session, config[CONF_DEVICES], async_see)

Expand Down