mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Use reference strings in elgato (#41063)
* Update strings.json * Update config_flow.py * Update test_config_flow.py
This commit is contained in:
parent
d282694efe
commit
6a821d6a64
@ -33,7 +33,7 @@ class ElgatoFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
user_input[CONF_HOST], user_input[CONF_PORT]
|
user_input[CONF_HOST], user_input[CONF_PORT]
|
||||||
)
|
)
|
||||||
except ElgatoError:
|
except ElgatoError:
|
||||||
return self._show_setup_form({"base": "connection_error"})
|
return self._show_setup_form({"base": "cannot_connect"})
|
||||||
|
|
||||||
# Check if already configured
|
# Check if already configured
|
||||||
await self.async_set_unique_id(info.serial_number)
|
await self.async_set_unique_id(info.serial_number)
|
||||||
@ -53,14 +53,14 @@ class ElgatoFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
"""Handle zeroconf discovery."""
|
"""Handle zeroconf discovery."""
|
||||||
if user_input is None:
|
if user_input is None:
|
||||||
return self.async_abort(reason="connection_error")
|
return self.async_abort(reason="cannot_connect")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
info = await self._get_elgato_info(
|
info = await self._get_elgato_info(
|
||||||
user_input[CONF_HOST], user_input[CONF_PORT]
|
user_input[CONF_HOST], user_input[CONF_PORT]
|
||||||
)
|
)
|
||||||
except ElgatoError:
|
except ElgatoError:
|
||||||
return self.async_abort(reason="connection_error")
|
return self.async_abort(reason="cannot_connect")
|
||||||
|
|
||||||
# Check if already configured
|
# Check if already configured
|
||||||
await self.async_set_unique_id(info.serial_number)
|
await self.async_set_unique_id(info.serial_number)
|
||||||
@ -92,7 +92,7 @@ class ElgatoFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
self.context.get(CONF_HOST), self.context.get(CONF_PORT)
|
self.context.get(CONF_HOST), self.context.get(CONF_PORT)
|
||||||
)
|
)
|
||||||
except ElgatoError:
|
except ElgatoError:
|
||||||
return self.async_abort(reason="connection_error")
|
return self.async_abort(reason="cannot_connect")
|
||||||
|
|
||||||
# Check if already configured
|
# Check if already configured
|
||||||
await self.async_set_unique_id(info.serial_number)
|
await self.async_set_unique_id(info.serial_number)
|
||||||
|
@ -15,11 +15,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"connection_error": "Failed to connect to Elgato Key Light device."
|
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]"
|
||||||
},
|
},
|
||||||
"abort": {
|
"abort": {
|
||||||
"already_configured": "This Elgato Key Light device is already configured.",
|
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]",
|
||||||
"connection_error": "Failed to connect to Elgato Key Light device."
|
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ async def test_connection_error(
|
|||||||
data={CONF_HOST: "1.2.3.4", CONF_PORT: 9123},
|
data={CONF_HOST: "1.2.3.4", CONF_PORT: 9123},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["errors"] == {"base": "connection_error"}
|
assert result["errors"] == {"base": "cannot_connect"}
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ async def test_zeroconf_connection_error(
|
|||||||
data={"host": "1.2.3.4", "port": 9123},
|
data={"host": "1.2.3.4", "port": 9123},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["reason"] == "connection_error"
|
assert result["reason"] == "cannot_connect"
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||||
|
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ async def test_zeroconf_confirm_connection_error(
|
|||||||
user_input={CONF_HOST: "1.2.3.4", CONF_PORT: 9123}
|
user_input={CONF_HOST: "1.2.3.4", CONF_PORT: 9123}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["reason"] == "connection_error"
|
assert result["reason"] == "cannot_connect"
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||||
|
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ async def test_zeroconf_no_data(
|
|||||||
flow.hass = hass
|
flow.hass = hass
|
||||||
result = await flow.async_step_zeroconf()
|
result = await flow.async_step_zeroconf()
|
||||||
|
|
||||||
assert result["reason"] == "connection_error"
|
assert result["reason"] == "cannot_connect"
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user