Ignore UpnpXmlContentError in SamsungTV (#72056)

This commit is contained in:
epenet 2022-05-18 09:36:20 +02:00 committed by Paulus Schoutsen
parent 6b0c7a2dd4
commit a1df9c33aa
2 changed files with 6 additions and 2 deletions

View File

@ -16,6 +16,7 @@ from async_upnp_client.exceptions import (
UpnpConnectionError,
UpnpError,
UpnpResponseError,
UpnpXmlContentError,
)
from async_upnp_client.profiles.dlna import DmrDevice
from async_upnp_client.utils import async_get_local_ip
@ -271,11 +272,12 @@ class SamsungTVDevice(MediaPlayerEntity):
# NETWORK,NONE
upnp_factory = UpnpFactory(upnp_requester, non_strict=True)
upnp_device: UpnpDevice | None = None
with contextlib.suppress(UpnpConnectionError, UpnpResponseError):
try:
upnp_device = await upnp_factory.async_create_device(
self._ssdp_rendering_control_location
)
if not upnp_device:
except (UpnpConnectionError, UpnpResponseError, UpnpXmlContentError) as err:
LOGGER.debug("Unable to create Upnp DMR device: %r", err, exc_info=True)
return
_, event_ip = await async_get_local_ip(
self._ssdp_rendering_control_location, self.hass.loop

View File

@ -1370,6 +1370,7 @@ async def test_upnp_not_available(
) -> None:
"""Test for volume control when Upnp is not available."""
await setup_samsungtv_entry(hass, MOCK_ENTRY_WS)
assert "Unable to create Upnp DMR device" in caplog.text
# Upnp action fails
assert await hass.services.async_call(
@ -1387,6 +1388,7 @@ async def test_upnp_missing_service(
) -> None:
"""Test for volume control when Upnp is not available."""
await setup_samsungtv_entry(hass, MOCK_ENTRY_WS)
assert "Unable to create Upnp DMR device" in caplog.text
# Upnp action fails
assert await hass.services.async_call(