Skip to content

Commit

Permalink
Ensure frontier_silicon config flow title_placeholders items are [str…
Browse files Browse the repository at this point in the history
…, str] (#127197)
  • Loading branch information
emontnemery authored Oct 2, 2024
1 parent 375d47e commit 47985a5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
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

0 comments on commit 47985a5

Please sign in to comment.