fix: ikea_bulb_device_set listener registration crash + ConfigEntryNotReady on connection failure#13
Open
pablotoledo wants to merge 1 commit intonrbrt:mainfrom
Conversation
…dy on connection failure Two bugs fixed that together caused the Dirigera integration to require manual reloads ~20 times before successfully loading after HA restart. Fix 1 (light.py): wrap ikea_bulb_device_set in registry_entry() Fix 2 (__init__.py): raise ConfigEntryNotReady on ConnectionError/OSError
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two related bugs that together caused the Dirigera integration to require ~20 manual reloads before successfully loading after a Home Assistant restart. Both issues were reproduced and verified on a production HA 2025.10.3 instance with the integration running inside a Docker bridge network.
Bug 1:
ikea_bulb_device_setcrashes the hub event listener immediately after setupRoot cause
In
light.py,ikea_bulb_device_setregisters itself directly into thehub_event_listenerdevice registry:All other entities (via
base_classes.py) register aregistry_entrywrapper:When
sync_all_device_areas()iterates the device registry and callsregistry_entry.entity, it works for all normal entities (because their registry value is aregistry_entryobject with an.entityproperty). But forikea_bulb_device_set, the registry value is the entity itself — aLightEntitysubclass with no.entityattribute — causing an immediateAttributeError.Observed log errors
This crash happens on every startup that has bulbs grouped in a device set. Once the listener dies, the integration enters a broken state and all subsequent device polling fails.
Fix
registry_entryis already imported inlight.pyfrom.hub_event_listener, so no import changes are needed.Bug 2:
async_setup_entrydoes not handle connection failures gracefullyRoot cause
async_setup_entrycallsmake_devices()with no exception handling. If the hub is temporarily unreachable during HA startup (e.g., brief network unavailability in Docker bridge environments, hub booting up, any transient OS-level network error), therequests.exceptions.ConnectionErrororOSErrorpropagates uncaught.Home Assistant interprets this as a permanent failure and marks the entry as
setup_error— which has no automatic retry. The correct HA pattern for transient connection failures is to raiseConfigEntryNotReady, which triggers HA's built-in exponential backoff retry mechanism.Observed behaviour
setup_error(permanent, no retry)[Errno 101] Network unreachableduringget_scenes/get_blinds/get_lightscalls withinmake_devicesEven with perfect hardware (both HA server and Dirigera hub wired to the same switch), Docker bridge containers can briefly get
ENETUNREACHduring early startup before routing tables and ARP caches stabilize.Fix
Results after both fixes
Tested on HA 2025.10.3,
dirigera_platforminstalled via HACS, Dirigera hub at 192.168.0.80, HA running in Docker bridge network:setup_error(no retry)loadedin ~10sikea_bulb_device_setAttributeErrorFailed to create listenerTemperaturasensorThe integration now loads cleanly on first attempt. If a transient connection failure occurs (e.g., at container startup), HA retries automatically instead of requiring manual intervention.
Files changed
custom_components/dirigera_platform/light.py— 1 line changedcustom_components/dirigera_platform/__init__.py— 7 lines added