mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +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]
|
self.hass, user_input[CONF_API_KEY]
|
||||||
)
|
)
|
||||||
if not api_online:
|
if not api_online:
|
||||||
errors["base"] = "auth"
|
errors["base"] = "invalid_api_key"
|
||||||
except UnauthorizedError:
|
except UnauthorizedError:
|
||||||
errors["base"] = "auth"
|
errors["base"] = "invalid_api_key"
|
||||||
except APICallError:
|
except APICallError:
|
||||||
errors["base"] = "connection"
|
errors["base"] = "cannot_connect"
|
||||||
|
|
||||||
if not errors:
|
if not errors:
|
||||||
return self.async_create_entry(
|
return self.async_create_entry(
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
{
|
{
|
||||||
"config": {
|
"config": {
|
||||||
"abort": {
|
"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": {
|
"error": {
|
||||||
"auth": "API key is not correct.",
|
"invalid_api_key": "[%key:common::config_flow::error::invalid_api_key%]",
|
||||||
"connection": "Can't connect to OWM API"
|
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]"
|
||||||
},
|
},
|
||||||
"step": {
|
"step": {
|
||||||
"user": {
|
"user": {
|
||||||
"data": {
|
"data": {
|
||||||
"api_key": "OpenWeatherMap API key",
|
"api_key": "[%key:common::config_flow::data::api_key%]",
|
||||||
"language": "Language",
|
"language": "Language",
|
||||||
"latitude": "[%key:common::config_flow::data::latitude%]",
|
"latitude": "[%key:common::config_flow::data::latitude%]",
|
||||||
"longitude": "[%key:common::config_flow::data::longitude%]",
|
"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
|
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):
|
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
|
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):
|
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
|
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):
|
def _create_mocked_owm(is_api_online: bool):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user