mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Try to request current_location Automatic scope (#7447)
This commit is contained in:
parent
71b4afb780
commit
8c90fd19ff
@ -31,7 +31,8 @@ CONF_DEVICES = 'devices'
|
|||||||
|
|
||||||
DEFAULT_TIMEOUT = 5
|
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'
|
ATTR_FUEL_LEVEL = 'fuel_level'
|
||||||
|
|
||||||
@ -58,8 +59,17 @@ def async_setup_scanner(hass, config, async_see, discovery_info=None):
|
|||||||
client_session=async_get_clientsession(hass),
|
client_session=async_get_clientsession(hass),
|
||||||
request_kwargs={'timeout': DEFAULT_TIMEOUT})
|
request_kwargs={'timeout': DEFAULT_TIMEOUT})
|
||||||
try:
|
try:
|
||||||
session = yield from client.create_session_from_password(
|
try:
|
||||||
SCOPE, config[CONF_USERNAME], config[CONF_PASSWORD])
|
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(
|
data = AutomaticData(
|
||||||
hass, client, session, config[CONF_DEVICES], async_see)
|
hass, client, session, config[CONF_DEVICES], async_see)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user