dlna_dmr: Ignore philips tv (#60204)

This commit is contained in:
Michael Chisholm 2021-11-24 09:22:34 +11:00 committed by GitHub
parent 4649bc3c11
commit 9fa6daf47a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 0 deletions

View File

@ -236,6 +236,10 @@ class DlnaDmrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
)
return self.async_abort(reason="already_in_progress")
# Abort if another config entry has the same location, in case the
# device doesn't have a static and unique UDN (breaking the UPnP spec).
self._async_abort_entries_match({CONF_URL: self._location})
self.context["title_placeholders"] = {"name": self._name}
return await self.async_step_confirm()
@ -478,6 +482,11 @@ def _is_ignored_device(discovery_info: Mapping[str, Any]) -> bool:
if manufacturer.startswith("xbmc") or model == "kodi":
# kodi
return True
if "philips" in manufacturer and "tv" in model:
# philips_js
# These TVs don't have a stable UDN, so also get discovered as a new
# device every time they are turned on.
return True
if manufacturer.startswith("samsung") and "tv" in model:
# samsungtv
return True

View File

@ -558,6 +558,21 @@ async def test_ssdp_flow_existing(
assert config_entry_mock.data[CONF_URL] == NEW_DEVICE_LOCATION
async def test_ssdp_flow_duplicate_location(
hass: HomeAssistant, config_entry_mock: MockConfigEntry
) -> None:
"""Test that discovery of device with URL matching existing entry gets aborted."""
config_entry_mock.add_to_hass(hass)
result = await hass.config_entries.flow.async_init(
DLNA_DOMAIN,
context={"source": config_entries.SOURCE_SSDP},
data=MOCK_DISCOVERY,
)
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert result["reason"] == "already_configured"
assert config_entry_mock.data[CONF_URL] == MOCK_DEVICE_LOCATION
async def test_ssdp_flow_upnp_udn(
hass: HomeAssistant, config_entry_mock: MockConfigEntry
) -> None:
@ -635,6 +650,7 @@ async def test_ssdp_ignore_device(hass: HomeAssistant) -> None:
("XBMC Foundation", "Kodi"),
("Samsung", "Smart TV"),
("LG Electronics.", "LG TV"),
("Royal Philips Electronics", "Philips TV DMR"),
]:
discovery = dict(MOCK_DISCOVERY)
discovery[ssdp.ATTR_UPNP_MANUFACTURER] = manufacturer