diff --git a/homeassistant/components/vallox/config_flow.py b/homeassistant/components/vallox/config_flow.py index dd6c57e7e63..1658a987263 100644 --- a/homeassistant/components/vallox/config_flow.py +++ b/homeassistant/components/vallox/config_flow.py @@ -13,6 +13,7 @@ from homeassistant.const import CONF_HOST, CONF_NAME from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResult from homeassistant.exceptions import HomeAssistantError +from homeassistant.loader import async_get_integration from homeassistant.util.network import is_ip_address from .const import DEFAULT_NAME, DOMAIN @@ -59,10 +60,10 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): try: await validate_host(self.hass, host) except InvalidHost: - _LOGGER.exception("An invalid host is configured for Vallox") + _LOGGER.error("An invalid host is configured for Vallox: %s", host) reason = "invalid_host" except VALLOX_CONNECTION_EXCEPTIONS: - _LOGGER.exception("Cannot connect to Vallox") + _LOGGER.error("Cannot connect to Vallox host %s", host) reason = "cannot_connect" except Exception: # pylint: disable=broad-except _LOGGER.exception("Unexpected exception") @@ -82,9 +83,15 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): self, user_input: dict[str, Any] | None = None ) -> FlowResult: """Handle the initial step.""" - if user_input is None or user_input[CONF_HOST] is None: + integration = await async_get_integration(self.hass, DOMAIN) + + if user_input is None: return self.async_show_form( - step_id="user", data_schema=STEP_USER_DATA_SCHEMA + step_id="user", + description_placeholders={ + "integration_docs_url": integration.documentation + }, + data_schema=STEP_USER_DATA_SCHEMA, ) errors = {} @@ -112,7 +119,12 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): ) return self.async_show_form( - step_id="user", data_schema=STEP_USER_DATA_SCHEMA, errors=errors + step_id="user", + description_placeholders={ + "integration_docs_url": integration.documentation + }, + data_schema=STEP_USER_DATA_SCHEMA, + errors=errors, ) diff --git a/homeassistant/components/vallox/strings.json b/homeassistant/components/vallox/strings.json index 496454ce991..dd341228db8 100644 --- a/homeassistant/components/vallox/strings.json +++ b/homeassistant/components/vallox/strings.json @@ -3,19 +3,22 @@ "step": { "user": { "title": "Vallox", - "description": "Set up the Vallox integration. If you have problems with configuration go to https://www.home-assistant.io/integrations/vallox.", + "description": "Set up the Vallox integration. If you have problems with configuration go to {integration_docs_url}.", "data": { - "host": "[%key:common::config_flow::data::host%]", - "name": "[%key:common::config_flow::data::name%]" + "host": "[%key:common::config_flow::data::host%]" } } }, "abort": { - "already_configured": "[%key:common::config_flow::abort::already_configured_service%]" + "already_configured": "[%key:common::config_flow::abort::already_configured_service%]", + "cannot_connect": "[%key:common::config_flow::error::cannot_connect%]", + "invalid_host": "[%key:common::config_flow::error::invalid_host%]", + "unknown": "[%key:common::config_flow::error::unknown%]" }, "error": { "cannot_connect": "[%key:common::config_flow::error::cannot_connect%]", - "invalid_host": "[%key:common::config_flow::error::invalid_host%]" + "invalid_host": "[%key:common::config_flow::error::invalid_host%]", + "unknown": "[%key:common::config_flow::error::unknown%]" } } } diff --git a/homeassistant/components/vallox/translations/en.json b/homeassistant/components/vallox/translations/en.json index ec4cce0bc62..d677ccead08 100644 --- a/homeassistant/components/vallox/translations/en.json +++ b/homeassistant/components/vallox/translations/en.json @@ -1,19 +1,22 @@ { "config": { "abort": { - "already_configured": "Service is already configured" + "already_configured": "Service is already configured", + "cannot_connect": "Failed to connect", + "invalid_host": "Invalid hostname or IP address", + "unknown": "Unknown error" }, "error": { "cannot_connect": "Failed to connect", - "invalid_host": "Invalid hostname or IP address" + "invalid_host": "Invalid hostname or IP address", + "unknown": "Unknown error" }, "step": { "user": { "data": { - "host": "Host", - "name": "Name" + "host": "Host" }, - "description": "Set up the Vallox integration. If you have problems with configuration go to https://www.home-assistant.io/integrations/vallox.", + "description": "Set up the Vallox integration. If you have problems with configuration go to {integration_docs_url}.", "title": "Vallox" } } diff --git a/tests/components/vallox/test_config_flow.py b/tests/components/vallox/test_config_flow.py index 89d9e5986ff..ee6b05f1f8b 100644 --- a/tests/components/vallox/test_config_flow.py +++ b/tests/components/vallox/test_config_flow.py @@ -241,7 +241,7 @@ async def test_import_already_configured(hass: HomeAssistant) -> None: assert result["reason"] == "already_configured" -async def test_import_cannot_connect_OSError(hass: HomeAssistant) -> None: +async def test_import_cannot_connect_os_error(hass: HomeAssistant) -> None: """Test that cannot connect error is handled.""" name = "Vallox 90 MV" @@ -260,7 +260,7 @@ async def test_import_cannot_connect_OSError(hass: HomeAssistant) -> None: assert result["reason"] == "cannot_connect" -async def test_import_cannot_connect_ValloxApiException(hass: HomeAssistant) -> None: +async def test_import_cannot_connect_vallox_api_exception(hass: HomeAssistant) -> None: """Test that cannot connect error is handled.""" name = "Vallox 90 MV"