Skip to content

Commit 80d52e6

Browse files
committed
fix: register ikea_bulb_device_set with registry_entry and handle connection errors with ConfigEntryNotReady
1 parent 55b8728 commit 80d52e6

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

custom_components/dirigera_platform/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import voluptuous as vol
1313

1414
from homeassistant import config_entries, core
15+
from homeassistant.exceptions import ConfigEntryNotReady
1516
from homeassistant.components.light import PLATFORM_SCHEMA
1617
from homeassistant.const import CONF_IP_ADDRESS, CONF_TOKEN, Platform
1718

@@ -195,7 +196,12 @@ async def async_setup_entry(
195196
platform = ikea_gateway()
196197
hass.data[DOMAIN][PLATFORM] = platform
197198
logger.debug("Starting make_devices...")
198-
await platform.make_devices(hass,hass_data[CONF_IP_ADDRESS], hass_data[CONF_TOKEN])
199+
try:
200+
await platform.make_devices(hass,hass_data[CONF_IP_ADDRESS], hass_data[CONF_TOKEN])
201+
except (ConnectionError, OSError) as err:
202+
raise ConfigEntryNotReady(
203+
f"Cannot connect to IKEA Dirigera hub at {hass_data[CONF_IP_ADDRESS]}: {err}"
204+
) from err
199205

200206
#await hass.async_add_executor_job(platform.make_devices,hass, hass_data[CONF_IP_ADDRESS], hass_data[CONF_TOKEN])
201207

custom_components/dirigera_platform/light.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ def available(self):
394394
def device_info(self) -> DeviceInfo:
395395

396396
# Register the device for updates
397-
hub_event_listener.register(self.unique_id, self)
397+
hub_event_listener.register(self.unique_id, registry_entry(self))
398398

399399
return DeviceInfo(
400400
identifiers={("dirigera_platform", self._device_set.id)},

0 commit comments

Comments
 (0)