Skip to content
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

Ensure frontier_silicon config flow title_placeholders items are [str, str] #127197

Merged
merged 2 commits into from
Oct 2, 2024
Merged
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: 3 additions & 2 deletions homeassistant/components/frontier_silicon/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ async def async_step_ssdp(
if device_hostname == hostname_from_url(entry.data[CONF_WEBFSAPI_URL]):
return self.async_abort(reason="already_configured")

speaker_name = discovery_info.ssdp_headers.get(SSDP_ATTR_SPEAKER_NAME)
self.context["title_placeholders"] = {"name": speaker_name}
if speaker_name := discovery_info.ssdp_headers.get(SSDP_ATTR_SPEAKER_NAME):
# If we have a name, use it as flow title
self.context["title_placeholders"] = {"name": speaker_name}

try:
self._webfsapi_url = await AFSAPI.get_webfsapi_endpoint(device_url)
Expand Down
7 changes: 7 additions & 0 deletions tests/components/frontier_silicon/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
ssdp_udn="uuid:3dcc7100-f76c-11dd-87af-00226124ca30",
ssdp_st="mock_st",
ssdp_location="http://1.1.1.1/device",
ssdp_headers={"SPEAKER-NAME": "Speaker Name"},
upnp={"SPEAKER-NAME": "Speaker Name"},
)

Expand All @@ -34,6 +35,7 @@
ssdp_udn="uuid:3dcc7100-f76c-11dd-87af-00226124ca30",
ssdp_st="mock_st",
ssdp_location=None,
ssdp_headers={"SPEAKER-NAME": "Speaker Name"},
upnp={"SPEAKER-NAME": "Speaker Name"},
)

Expand Down Expand Up @@ -268,6 +270,11 @@ async def test_ssdp(
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm"

flows = hass.config_entries.flow.async_progress()
assert len(flows) == 1
flow = flows[0]
assert flow["context"]["title_placeholders"] == {"name": "Speaker Name"}

result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
{},
Expand Down