Skip to content

Remove entity name input from Samsung TV config flow #144225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions homeassistant/components/samsungtv/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
UPNP_SVC_RENDERING_CONTROL,
)

DATA_SCHEMA = vol.Schema({vol.Required(CONF_HOST): str, vol.Required(CONF_NAME): str})
DATA_SCHEMA = vol.Schema({vol.Required(CONF_HOST): str})


def _strip_uuid(udn: str) -> str:
Expand Down Expand Up @@ -261,8 +261,7 @@ async def _async_set_name_host_from_input(self, user_input: dict[str, Any]) -> N
)
except socket.gaierror as err:
raise AbortFlow(RESULT_UNKNOWN_HOST) from err
self._name = user_input.get(CONF_NAME, self._host) or ""
self._title = self._name
self._title = self._host

async def async_step_user(
self, user_input: dict[str, Any] | None = None
Expand Down
11 changes: 5 additions & 6 deletions tests/components/samsungtv/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
CONF_NAME: "fake",
CONF_PORT: 8002,
}
MOCK_USER_DATA = {CONF_HOST: "fake_host", CONF_NAME: "fake_name"}
MOCK_USER_DATA = {CONF_HOST: "fake_host"}

MOCK_DHCP_DATA = DhcpServiceInfo(
ip="fake_host", macaddress="aabbccddeeff", hostname="fake_hostname"
Expand Down Expand Up @@ -176,9 +176,8 @@ async def test_user_legacy(hass: HomeAssistant) -> None:
)
# legacy tv entry created
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "fake_name"
assert result["title"] == "fake_host"
assert result["data"][CONF_HOST] == "fake_host"
assert result["data"][CONF_NAME] == "fake_name"
assert result["data"][CONF_METHOD] == "legacy"
assert result["data"][CONF_MANUFACTURER] == DEFAULT_MANUFACTURER
assert result["data"][CONF_MODEL] is None
Expand Down Expand Up @@ -211,9 +210,8 @@ async def test_user_legacy_does_not_ok_first_time(hass: HomeAssistant) -> None:

# legacy tv entry created
assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["title"] == "fake_name"
assert result3["title"] == "fake_host"
assert result3["data"][CONF_HOST] == "fake_host"
assert result3["data"][CONF_NAME] == "fake_name"
assert result3["data"][CONF_METHOD] == "legacy"
assert result3["data"][CONF_MANUFACTURER] == DEFAULT_MANUFACTURER
assert result3["data"][CONF_MODEL] is None
Expand Down Expand Up @@ -1255,7 +1253,8 @@ async def test_autodetect_legacy(hass: HomeAssistant) -> None:
)
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"][CONF_METHOD] == "legacy"
assert result["data"][CONF_NAME] == "fake_name"
# friendly name cannot be detected for legacy TV
assert result["data"][CONF_NAME] is None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we testing is None?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only because other fields are tested for None as well.

PR updated

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think conf_name needs a thorough review, as it seems to be passed and used by the legacy bridge

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If name was set previously, then we still might want to respect this.

assert result["data"][CONF_MAC] is None
assert result["data"][CONF_PORT] == LEGACY_PORT

Expand Down