Ignore UpnpXmlContentError in SamsungTV (#72056)

pull/72059/head
epenet 2022-05-18 09:36:20 +02:00 committed by GitHub
parent 12020ffac1
commit 8d57f70466
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -15,6 +15,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
@ -270,11 +271,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

@ -1368,6 +1368,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(
@ -1385,6 +1386,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(