1
mirror of https://github.com/home-assistant/core synced 2024-09-06 10:29:55 +02:00

Move life360 I/O out of event loop in config flow (#35193)

This commit is contained in:
Phil Bruckner 2020-05-04 14:58:16 -05:00 committed by GitHub
parent 8279efc164
commit d8ebdda714
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -47,8 +47,8 @@ class Life360ConfigFlow(config_entries.ConfigFlow):
try:
# pylint: disable=no-value-for-parameter
vol.Email()(self._username)
authorization = self._api.get_authorization(
self._username, self._password
authorization = await self.hass.async_add_executor_job(
self._api.get_authorization, self._username, self._password
)
except vol.Invalid:
errors[CONF_USERNAME] = "invalid_username"
@ -89,7 +89,9 @@ class Life360ConfigFlow(config_entries.ConfigFlow):
username = user_input[CONF_USERNAME]
password = user_input[CONF_PASSWORD]
try:
authorization = self._api.get_authorization(username, password)
authorization = await self.hass.async_add_executor_job(
self._api.get_authorization, username, password
)
except LoginError:
_LOGGER.error("Invalid credentials for %s", username)
return self.async_abort(reason="invalid_credentials")