diff --git a/custom_components/hikvision_next/__init__.py b/custom_components/hikvision_next/__init__.py index f7da136..4e9b826 100644 --- a/custom_components/hikvision_next/__init__.py +++ b/custom_components/hikvision_next/__init__.py @@ -5,6 +5,7 @@ import asyncio from contextlib import suppress import logging +import traceback from httpx import TimeoutException @@ -59,12 +60,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: device_info = isapi.hass_device_info() device_registry = dr.async_get(hass) device_registry.async_get_or_create(config_entry_id=entry.entry_id, **device_info) - except (asyncio.TimeoutError, TimeoutException) as ex: + except (TimeoutError, TimeoutException) as ex: raise ConfigEntryNotReady(f"Timeout while connecting to {host}. Cannot initialize {DOMAIN}") from ex except Exception as ex: # pylint: disable=broad-except - raise ConfigEntryNotReady( - f"Unknown error connecting to {host}. Cannot initialize {DOMAIN}. Error is {ex}" - ) from ex + msg = f"Cannot initialize {DOMAIN} {host}. Error: {ex}\n" + _LOGGER.error(msg + traceback.format_exc()) + raise ConfigEntryNotReady(msg) from ex coordinators = {} diff --git a/custom_components/hikvision_next/isapi.py b/custom_components/hikvision_next/isapi.py index cd9f67d..20ad8c4 100644 --- a/custom_components/hikvision_next/isapi.py +++ b/custom_components/hikvision_next/isapi.py @@ -440,6 +440,8 @@ def get_event(event_trigger: dict): supported_events = deep_get(event_notification, "EventTriggerList.EventTrigger", []) else: supported_events = deep_get(event_triggers, "EventTriggerList.EventTrigger", []) + if not isinstance(supported_events, list): + supported_events = [supported_events] for event_trigger in supported_events: if event := get_event(event_trigger):