diff --git a/custom_components/dirigera_platform/__init__.py b/custom_components/dirigera_platform/__init__.py index 8a89a5e..610eb1e 100644 --- a/custom_components/dirigera_platform/__init__.py +++ b/custom_components/dirigera_platform/__init__.py @@ -12,6 +12,8 @@ import voluptuous as vol from homeassistant import config_entries, core +from homeassistant.exceptions import ConfigEntryNotReady +import requests as _requests from homeassistant.components.light import PLATFORM_SCHEMA from homeassistant.const import CONF_IP_ADDRESS, CONF_TOKEN, Platform @@ -195,7 +197,12 @@ async def async_setup_entry( platform = ikea_gateway() hass.data[DOMAIN][PLATFORM] = platform logger.debug("Starting make_devices...") - await platform.make_devices(hass,hass_data[CONF_IP_ADDRESS], hass_data[CONF_TOKEN]) + try: + await platform.make_devices(hass,hass_data[CONF_IP_ADDRESS], hass_data[CONF_TOKEN]) + except (_requests.exceptions.ConnectionError, OSError) as err: + raise ConfigEntryNotReady( + f"Cannot connect to IKEA Dirigera hub at {hass_data[CONF_IP_ADDRESS]}: {err}" + ) from err #await hass.async_add_executor_job(platform.make_devices,hass, hass_data[CONF_IP_ADDRESS], hass_data[CONF_TOKEN]) diff --git a/custom_components/dirigera_platform/light.py b/custom_components/dirigera_platform/light.py index dd0b60f..046700f 100644 --- a/custom_components/dirigera_platform/light.py +++ b/custom_components/dirigera_platform/light.py @@ -394,7 +394,7 @@ def available(self): def device_info(self) -> DeviceInfo: # Register the device for updates - hub_event_listener.register(self.unique_id, self) + hub_event_listener.register(self.unique_id, registry_entry(self)) return DeviceInfo( identifiers={("dirigera_platform", self._device_set.id)},