mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +00:00
Abort samsungtv discovery of legacy devices when unique id not available (#69376)
This commit is contained in:
parent
f31d1164e5
commit
4b5033d08f
@ -469,6 +469,13 @@ class SamsungTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
await self._async_set_unique_id_from_udn()
|
||||
self._async_update_and_abort_for_matching_unique_id()
|
||||
self._async_abort_if_host_already_in_progress()
|
||||
if self._method == METHOD_LEGACY and discovery_info.ssdp_st in (
|
||||
UPNP_SVC_RENDERING_CONTROL,
|
||||
UPNP_SVC_MAIN_TV_AGENT,
|
||||
):
|
||||
# The UDN we use for the unique id cannot be determined
|
||||
# from device_info for legacy devices
|
||||
return self.async_abort(reason="not_supported")
|
||||
self.context["title_placeholders"] = {"device": self._title}
|
||||
return await self.async_step_confirm()
|
||||
|
||||
|
@ -43,6 +43,7 @@ from homeassistant.components.ssdp import (
|
||||
ATTR_UPNP_MANUFACTURER,
|
||||
ATTR_UPNP_MODEL_NAME,
|
||||
ATTR_UPNP_UDN,
|
||||
SsdpServiceInfo,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
CONF_HOST,
|
||||
@ -524,6 +525,21 @@ async def test_ssdp(hass: HomeAssistant) -> None:
|
||||
assert result["result"].unique_id == "0d1cef00-00dc-1000-9c80-4844f7b172de"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"data", [MOCK_SSDP_DATA_MAIN_TV_AGENT_ST, MOCK_SSDP_DATA_RENDERING_CONTROL_ST]
|
||||
)
|
||||
@pytest.mark.usefixtures("remote", "rest_api_failing")
|
||||
async def test_ssdp_legacy_not_remote_control_receiver_udn(
|
||||
hass: HomeAssistant, data: SsdpServiceInfo
|
||||
) -> None:
|
||||
"""Test we abort if the st is not usable for legacy discovery since it will have a different UDN."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=data
|
||||
)
|
||||
assert result["type"] == RESULT_TYPE_ABORT
|
||||
assert result["reason"] == RESULT_NOT_SUPPORTED
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("remote", "rest_api_failing")
|
||||
async def test_ssdp_noprefix(hass: HomeAssistant) -> None:
|
||||
"""Test starting a flow from discovery without prefixes."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user