mirror of
https://github.com/Electric-Special/ha-core.git
synced 2026-03-21 03:03:17 +01:00
Change lunatone config entry title to only include the URL (#162855)
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user