Use reference strings in Smarthab (#41391)

This commit is contained in:
SNoof85 2020-10-07 14:39:30 +02:00 committed by GitHub
parent 4968a12b6c
commit 7c133e4630
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 7 deletions

View File

@ -65,13 +65,13 @@ class SmartHabConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
title=username, data={CONF_EMAIL: username, CONF_PASSWORD: password}
)
errors["base"] = "wrong_login"
errors["base"] = "invalid_auth"
except pysmarthab.RequestFailedException:
_LOGGER.exception("Error while trying to reach SmartHab API")
errors["base"] = "service"
except Exception: # pylint: disable=broad-except
_LOGGER.exception("Unexpected error during login")
errors["base"] = "unknown_error"
errors["base"] = "unknown"
return self._show_setup_form(user_input, errors)

View File

@ -2,8 +2,8 @@
"config": {
"error": {
"service": "Error while trying to reach SmartHab. Service might be down. Check your connection.",
"wrong_login": "[%key:common::config_flow::error::invalid_auth%]",
"unknown_error": "[%key:common::config_flow::error::unknown%]"
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]",
"unknown": "[%key:common::config_flow::error::unknown%]"
},
"step": {
"user": {
@ -16,4 +16,4 @@
}
}
}
}
}

View File

@ -55,7 +55,7 @@ async def test_form_invalid_auth(hass):
)
assert result2["type"] == "form"
assert result2["errors"] == {"base": "wrong_login"}
assert result2["errors"] == {"base": "invalid_auth"}
async def test_form_service_error(hass):
@ -93,7 +93,7 @@ async def test_form_unknown_error(hass):
)
assert result2["type"] == "form"
assert result2["errors"] == {"base": "unknown_error"}
assert result2["errors"] == {"base": "unknown"}
async def test_import(hass):