From f806cc8b4bd2cff675f79d11568bbf4003273322 Mon Sep 17 00:00:00 2001 From: Akanksha Date: Sun, 19 Oct 2025 00:28:29 +0530 Subject: [PATCH] Move translatable URL out of strings.json for airnow integration (#154557) Co-authored-by: jbouwh --- homeassistant/components/airnow/config_flow.py | 5 +++++ homeassistant/components/airnow/strings.json | 2 +- tests/components/airnow/test_config_flow.py | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/airnow/config_flow.py b/homeassistant/components/airnow/config_flow.py index 661e1b0a298..331fdb729f5 100644 --- a/homeassistant/components/airnow/config_flow.py +++ b/homeassistant/components/airnow/config_flow.py @@ -26,6 +26,10 @@ from .const import DOMAIN _LOGGER = logging.getLogger(__name__) +# Documentation URL for API key generation +_API_KEY_URL = "https://docs.airnowapi.org/account/request/" + + async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> bool: """Validate the user input allows us to connect. @@ -114,6 +118,7 @@ class AirNowConfigFlow(ConfigFlow, domain=DOMAIN): ), } ), + description_placeholders={"api_key_url": _API_KEY_URL}, errors=errors, ) diff --git a/homeassistant/components/airnow/strings.json b/homeassistant/components/airnow/strings.json index a69f67948cb..f6ccf858314 100644 --- a/homeassistant/components/airnow/strings.json +++ b/homeassistant/components/airnow/strings.json @@ -2,7 +2,7 @@ "config": { "step": { "user": { - "description": "To generate API key go to https://docs.airnowapi.org/account/request/", + "description": "To generate API key go to {api_key_url}", "data": { "api_key": "[%key:common::config_flow::data::api_key%]", "latitude": "[%key:common::config_flow::data::latitude%]", diff --git a/tests/components/airnow/test_config_flow.py b/tests/components/airnow/test_config_flow.py index 6507eea1fcb..759a21bc559 100644 --- a/tests/components/airnow/test_config_flow.py +++ b/tests/components/airnow/test_config_flow.py @@ -25,6 +25,9 @@ async def test_form( ) assert result["type"] is FlowResultType.FORM assert result["errors"] == {} + assert result["description_placeholders"] == { + "api_key_url": "https://docs.airnowapi.org/account/request/" + } result2 = await hass.config_entries.flow.async_configure(result["flow_id"], config) assert result2["type"] is FlowResultType.CREATE_ENTRY