Handle more Life360 errors in config flow & bump package to 4.1.1 (#25930)

pull/25953/head
Phil Bruckner 2019-08-14 11:15:37 -05:00 committed by Paulus Schoutsen
parent 002f74c76b
commit bd8461b899
5 changed files with 18 additions and 6 deletions

View File

@ -10,7 +10,8 @@
"error": {
"invalid_credentials": "Invalid credentials",
"invalid_username": "Invalid username",
"user_already_configured": "Account has already been configured"
"user_already_configured": "Account has already been configured",
"unexpected": "Unexpected error communicating with Life360 server"
},
"step": {
"user": {
@ -24,4 +25,4 @@
},
"title": "Life360"
}
}
}

View File

@ -2,7 +2,7 @@
from collections import OrderedDict
import logging
from life360 import LoginError
from life360 import Life360Error, LoginError
import voluptuous as vol
from homeassistant import config_entries
@ -54,6 +54,11 @@ class Life360ConfigFlow(config_entries.ConfigFlow):
errors[CONF_USERNAME] = "invalid_username"
except LoginError:
errors["base"] = "invalid_credentials"
except Life360Error as error:
_LOGGER.error(
"Unexpected error communicating with Life360 server: %s", error
)
errors["base"] = "unexpected"
else:
if self._username in self.configured_usernames:
errors["base"] = "user_already_configured"
@ -88,6 +93,11 @@ class Life360ConfigFlow(config_entries.ConfigFlow):
except LoginError:
_LOGGER.error("Invalid credentials for %s", username)
return self.async_abort(reason="invalid_credentials")
except Life360Error as error:
_LOGGER.error(
"Unexpected error communicating with Life360 server: %s", error
)
return self.async_abort(reason="unexpected")
return self.async_create_entry(
title="{} (from configuration)".format(username),
data={

View File

@ -8,6 +8,6 @@
"@pnbruckner"
],
"requirements": [
"life360==4.0.1"
"life360==4.1.1"
]
}

View File

@ -14,7 +14,8 @@
"error": {
"invalid_username": "Invalid username",
"invalid_credentials": "Invalid credentials",
"user_already_configured": "Account has already been configured"
"user_already_configured": "Account has already been configured",
"unexpected": "Unexpected error communicating with Life360 server"
},
"create_entry": {
"default": "To set advanced options, see [Life360 documentation]({docs_url})."

View File

@ -723,7 +723,7 @@ librouteros==2.3.0
libsoundtouch==0.7.2
# homeassistant.components.life360
life360==4.0.1
life360==4.1.1
# homeassistant.components.lifx_legacy
liffylights==0.9.4