From bd8461b8992c13b28657ab78c73357c1f8a6f514 Mon Sep 17 00:00:00 2001 From: Phil Bruckner Date: Wed, 14 Aug 2019 11:15:37 -0500 Subject: [PATCH] Handle more Life360 errors in config flow & bump package to 4.1.1 (#25930) --- .../components/life360/.translations/en.json | 5 +++-- homeassistant/components/life360/config_flow.py | 12 +++++++++++- homeassistant/components/life360/manifest.json | 2 +- homeassistant/components/life360/strings.json | 3 ++- requirements_all.txt | 2 +- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/life360/.translations/en.json b/homeassistant/components/life360/.translations/en.json index 2c187ba0470..d601c9cfe8e 100644 --- a/homeassistant/components/life360/.translations/en.json +++ b/homeassistant/components/life360/.translations/en.json @@ -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" } -} \ No newline at end of file +} diff --git a/homeassistant/components/life360/config_flow.py b/homeassistant/components/life360/config_flow.py index 9bd33981f37..be84d276422 100644 --- a/homeassistant/components/life360/config_flow.py +++ b/homeassistant/components/life360/config_flow.py @@ -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={ diff --git a/homeassistant/components/life360/manifest.json b/homeassistant/components/life360/manifest.json index 079344af6a6..9eae371070a 100644 --- a/homeassistant/components/life360/manifest.json +++ b/homeassistant/components/life360/manifest.json @@ -8,6 +8,6 @@ "@pnbruckner" ], "requirements": [ - "life360==4.0.1" + "life360==4.1.1" ] } diff --git a/homeassistant/components/life360/strings.json b/homeassistant/components/life360/strings.json index cff3f39e5d5..419f3650333 100644 --- a/homeassistant/components/life360/strings.json +++ b/homeassistant/components/life360/strings.json @@ -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})." diff --git a/requirements_all.txt b/requirements_all.txt index e62d28ff22c..36855c23bf1 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -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