mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Use reference strings for openweathermap (#41055)
This commit is contained in:
parent
4c00ff98ea
commit
8b30b6b312
@ -69,11 +69,11 @@ class OpenWeatherMapConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
self.hass, user_input[CONF_API_KEY]
|
||||
)
|
||||
if not api_online:
|
||||
errors["base"] = "auth"
|
||||
errors["base"] = "invalid_api_key"
|
||||
except UnauthorizedError:
|
||||
errors["base"] = "auth"
|
||||
errors["base"] = "invalid_api_key"
|
||||
except APICallError:
|
||||
errors["base"] = "connection"
|
||||
errors["base"] = "cannot_connect"
|
||||
|
||||
if not errors:
|
||||
return self.async_create_entry(
|
||||
|
@ -1,16 +1,16 @@
|
||||
{
|
||||
"config": {
|
||||
"abort": {
|
||||
"already_configured": "OpenWeatherMap integration for these coordinates is already configured."
|
||||
"already_configured": "[%key:common::config_flow::abort::already_configured_service%] for these coordinates."
|
||||
},
|
||||
"error": {
|
||||
"auth": "API key is not correct.",
|
||||
"connection": "Can't connect to OWM API"
|
||||
"invalid_api_key": "[%key:common::config_flow::error::invalid_api_key%]",
|
||||
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]"
|
||||
},
|
||||
"step": {
|
||||
"user": {
|
||||
"data": {
|
||||
"api_key": "OpenWeatherMap API key",
|
||||
"api_key": "[%key:common::config_flow::data::api_key%]",
|
||||
"language": "Language",
|
||||
"latitude": "[%key:common::config_flow::data::latitude%]",
|
||||
"longitude": "[%key:common::config_flow::data::longitude%]",
|
||||
|
@ -166,7 +166,7 @@ async def test_form_invalid_api_key(hass):
|
||||
DOMAIN, context={"source": SOURCE_USER}, data=CONFIG
|
||||
)
|
||||
|
||||
assert result["errors"] == {"base": "auth"}
|
||||
assert result["errors"] == {"base": "invalid_api_key"}
|
||||
|
||||
|
||||
async def test_form_api_call_error(hass):
|
||||
@ -182,7 +182,7 @@ async def test_form_api_call_error(hass):
|
||||
DOMAIN, context={"source": SOURCE_USER}, data=CONFIG
|
||||
)
|
||||
|
||||
assert result["errors"] == {"base": "connection"}
|
||||
assert result["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
async def test_form_api_offline(hass):
|
||||
@ -197,7 +197,7 @@ async def test_form_api_offline(hass):
|
||||
DOMAIN, context={"source": SOURCE_USER}, data=CONFIG
|
||||
)
|
||||
|
||||
assert result["errors"] == {"base": "auth"}
|
||||
assert result["errors"] == {"base": "invalid_api_key"}
|
||||
|
||||
|
||||
def _create_mocked_owm(is_api_online: bool):
|
||||
|
Loading…
x
Reference in New Issue
Block a user