mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 00:37:13 +00:00
Ensure onvif can still be unloaded if camera fails to unsubscribe (#91887)
This commit is contained in:
parent
c5d0c392a9
commit
6c024405a6
@ -1,7 +1,9 @@
|
||||
"""The ONVIF integration."""
|
||||
import logging
|
||||
|
||||
from httpx import RequestError
|
||||
from onvif.exceptions import ONVIFAuthError, ONVIFError, ONVIFTimeoutError
|
||||
from zeep.exceptions import Fault
|
||||
from zeep.exceptions import Fault, TransportError
|
||||
|
||||
from homeassistant.components.ffmpeg import CONF_EXTRA_ARGUMENTS
|
||||
from homeassistant.components.stream import CONF_RTSP_TRANSPORT, RTSP_TRANSPORTS
|
||||
@ -18,6 +20,8 @@ from homeassistant.exceptions import ConfigEntryNotReady
|
||||
from .const import CONF_SNAPSHOT_AUTH, DEFAULT_ARGUMENTS, DOMAIN
|
||||
from .device import ONVIFDevice
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Set up ONVIF from a config entry."""
|
||||
@ -79,7 +83,10 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
device: ONVIFDevice = hass.data[DOMAIN][entry.unique_id]
|
||||
|
||||
if device.capabilities.events and device.events.started:
|
||||
await device.events.async_stop()
|
||||
try:
|
||||
await device.events.async_stop()
|
||||
except (ONVIFError, Fault, RequestError, TransportError):
|
||||
LOGGER.warning("Error while stopping events: %s", device.name)
|
||||
|
||||
return await hass.config_entries.async_unload_platforms(entry, device.platforms)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user