From 8de1e3d27b119710481f0c90d8908f4934ef72ca Mon Sep 17 00:00:00 2001 From: MoonDevLT <107535193+MoonDevLT@users.noreply.github.com> Date: Wed, 18 Feb 2026 12:27:25 +0100 Subject: [PATCH] Change lunatone config entry title to only include the URL (#162855) --- homeassistant/components/lunatone/config_flow.py | 16 +++------------- tests/components/lunatone/conftest.py | 2 +- tests/components/lunatone/test_config_flow.py | 8 ++++---- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/homeassistant/components/lunatone/config_flow.py b/homeassistant/components/lunatone/config_flow.py index 4dc5d8c03ec..b5004ffdce4 100644 --- a/homeassistant/components/lunatone/config_flow.py +++ b/homeassistant/components/lunatone/config_flow.py @@ -22,11 +22,6 @@ DATA_SCHEMA: Final[vol.Schema] = vol.Schema( ) -def compose_title(name: str | None, serial_number: int) -> str: - """Compose a title string from a given name and serial number.""" - return f"{name or 'DALI Gateway'} {serial_number}" - - class LunatoneConfigFlow(ConfigFlow, domain=DOMAIN): """Lunatone config flow.""" @@ -54,22 +49,17 @@ class LunatoneConfigFlow(ConfigFlow, domain=DOMAIN): except aiohttp.ClientConnectionError: errors["base"] = "cannot_connect" else: - if info_api.data is None or info_api.serial_number is None: + if info_api.serial_number is None: errors["base"] = "missing_device_info" else: await self.async_set_unique_id(str(info_api.serial_number)) if self.source == SOURCE_RECONFIGURE: self._abort_if_unique_id_mismatch() return self.async_update_reload_and_abort( - self._get_reconfigure_entry(), - data_updates=data, - title=compose_title(info_api.name, info_api.serial_number), + self._get_reconfigure_entry(), data_updates=data, title=url ) self._abort_if_unique_id_configured() - return self.async_create_entry( - title=compose_title(info_api.name, info_api.serial_number), - data={CONF_URL: url}, - ) + return self.async_create_entry(title=url, data={CONF_URL: url}) return self.async_show_form( step_id="user", data_schema=DATA_SCHEMA, diff --git a/tests/components/lunatone/conftest.py b/tests/components/lunatone/conftest.py index abac3522d2b..318ff9ed38a 100644 --- a/tests/components/lunatone/conftest.py +++ b/tests/components/lunatone/conftest.py @@ -96,7 +96,7 @@ def mock_lunatone_dali_broadcast() -> Generator[AsyncMock]: def mock_config_entry() -> MockConfigEntry: """Return the default mocked config entry.""" return MockConfigEntry( - title=f"Lunatone {SERIAL_NUMBER}", + title=BASE_URL, domain=DOMAIN, data={CONF_URL: BASE_URL}, unique_id=str(SERIAL_NUMBER), diff --git a/tests/components/lunatone/test_config_flow.py b/tests/components/lunatone/test_config_flow.py index 56bae075a19..2ed358a54c0 100644 --- a/tests/components/lunatone/test_config_flow.py +++ b/tests/components/lunatone/test_config_flow.py @@ -11,7 +11,7 @@ from homeassistant.const import CONF_URL from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType -from . import BASE_URL, SERIAL_NUMBER +from . import BASE_URL from tests.common import MockConfigEntry @@ -32,7 +32,7 @@ async def test_full_flow( {CONF_URL: BASE_URL}, ) assert result["type"] is FlowResultType.CREATE_ENTRY - assert result["title"] == f"Test {SERIAL_NUMBER}" + assert result["title"] == BASE_URL assert result["data"] == {CONF_URL: BASE_URL} @@ -41,7 +41,7 @@ async def test_full_flow_fail_because_of_missing_device_infos( mock_lunatone_info: AsyncMock, ) -> None: """Test full flow.""" - mock_lunatone_info.data = None + mock_lunatone_info.serial_number = None result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER} @@ -117,7 +117,7 @@ async def test_user_step_fail_with_error( {CONF_URL: BASE_URL}, ) assert result["type"] is FlowResultType.CREATE_ENTRY - assert result["title"] == f"Test {SERIAL_NUMBER}" + assert result["title"] == BASE_URL assert result["data"] == {CONF_URL: BASE_URL}