Allow glances entries with same IP but different ports (#99536)

This commit is contained in:
Rami Mosleh 2023-09-03 20:22:59 +03:00 committed by GitHub
parent d19f617c25
commit ca44242095
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -61,11 +61,14 @@ class GlancesFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
"""Handle the initial step."""
errors = {}
if user_input is not None:
self._async_abort_entries_match({CONF_HOST: user_input[CONF_HOST]})
self._async_abort_entries_match(
{CONF_HOST: user_input[CONF_HOST], CONF_PORT: user_input[CONF_PORT]}
)
try:
await validate_input(self.hass, user_input)
return self.async_create_entry(
title=user_input[CONF_HOST], data=user_input
title=f"{user_input[CONF_HOST]}:{user_input[CONF_PORT]}",
data=user_input,
)
except CannotConnect:
errors["base"] = "cannot_connect"

View File

@ -35,7 +35,7 @@ async def test_form(hass: HomeAssistant) -> None:
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["title"] == "0.0.0.0"
assert result["title"] == "0.0.0.0:61208"
assert result["data"] == MOCK_USER_INPUT