diff --git a/homeassistant/components/velbus/config_flow.py b/homeassistant/components/velbus/config_flow.py index 361b5a01175..7d392ab37c5 100644 --- a/homeassistant/components/velbus/config_flow.py +++ b/homeassistant/components/velbus/config_flow.py @@ -37,7 +37,7 @@ class VelbusConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): try: controller = velbus.Controller(prt) except Exception: # pylint: disable=broad-except - self._errors[CONF_PORT] = "connection_failed" + self._errors[CONF_PORT] = "cannot_connect" return False controller.stop() return True @@ -58,7 +58,7 @@ class VelbusConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): if self._test_connection(prt): return self._create_device(name, prt) else: - self._errors[CONF_PORT] = "port_exists" + self._errors[CONF_PORT] = "already_configured" else: user_input = {} user_input[CONF_NAME] = "" @@ -82,5 +82,5 @@ class VelbusConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): if self._prt_in_configuration_exists(prt): # if the velbus import is already in the config # we should not proceed the import - return self.async_abort(reason="port_exists") + return self.async_abort(reason="already_configured") return await self.async_step_user(user_input) diff --git a/homeassistant/components/velbus/strings.json b/homeassistant/components/velbus/strings.json index d5f9d4e7ccf..c2defd782f4 100644 --- a/homeassistant/components/velbus/strings.json +++ b/homeassistant/components/velbus/strings.json @@ -10,9 +10,11 @@ } }, "error": { - "port_exists": "This port is already configured", - "connection_failed": "The velbus connection failed" + "already_configured": "[%key:common::config_flow::abort::already_configured_device%]", + "cannot_connect": "[%key:common::config_flow::error::cannot_connect%]" }, - "abort": { "port_exists": "This port is already configured" } + "abort": { + "already_configured": "[%key:common::config_flow::abort::already_configured_device%]" + } } } diff --git a/tests/components/velbus/test_config_flow.py b/tests/components/velbus/test_config_flow.py index 3bccacc0a94..0a7bc4489c7 100644 --- a/tests/components/velbus/test_config_flow.py +++ b/tests/components/velbus/test_config_flow.py @@ -65,13 +65,13 @@ async def test_user_fail(hass, controller_assert): {CONF_NAME: "Velbus Test Serial", CONF_PORT: PORT_SERIAL} ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM - assert result["errors"] == {CONF_PORT: "connection_failed"} + assert result["errors"] == {CONF_PORT: "cannot_connect"} result = await flow.async_step_user( {CONF_NAME: "Velbus Test TCP", CONF_PORT: PORT_TCP} ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM - assert result["errors"] == {CONF_PORT: "connection_failed"} + assert result["errors"] == {CONF_PORT: "cannot_connect"} async def test_import(hass, controller): @@ -94,10 +94,10 @@ async def test_abort_if_already_setup(hass): {CONF_PORT: PORT_TCP, CONF_NAME: "velbus import test"} ) assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT - assert result["reason"] == "port_exists" + assert result["reason"] == "already_configured" result = await flow.async_step_user( {CONF_PORT: PORT_TCP, CONF_NAME: "velbus import test"} ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM - assert result["errors"] == {"port": "port_exists"} + assert result["errors"] == {"port": "already_configured"}