Skip to content

Load initial data in the background so BLE setup doesn't block startup - #21

Merged
Nailik merged 1 commit into
Nailik:mainfrom
lackas:fix/non-blocking-setup
Sep 3, 2026
Merged

Load initial data in the background so BLE setup doesn't block startup#21
Nailik merged 1 commit into
Nailik:mainfrom
lackas:fix/non-blocking-setup

Conversation

@lackas

@lackas lackas commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

async_setup_entry awaited async_config_entry_first_refresh(), so the initial BLE connect + reads (up to the 120 s connect timeout) blocked config-entry setup — HA logged "Waiting for integrations to complete setup" for a minute or more.

Forward the platforms and run the first refresh in a background task instead. Entities already report unavailable until the coordinator has data, and it retries on its interval and on BLE rediscovery. Device resolution still runs in setup, so a missing device still raises ConfigEntryNotReady.

Tests: test_async_setup_entry_success updated; the three setup-time refresh-error tests removed (dead path).

async_setup_entry awaited async_config_entry_first_refresh(), so the
initial BLE connect + reads (up to the 120 s connect timeout) blocked
config-entry setup — HA logged "Waiting for integrations to complete
setup" for a minute or more.

Forward the platforms and run the first refresh in a background task
instead. Entities already report unavailable until the coordinator has
data, and it retries on its interval and on BLE rediscovery. Device
resolution still runs in setup, so a missing device still raises
ConfigEntryNotReady.

test_async_setup_entry_success updated; the three setup-time
refresh-error tests removed (dead path).
@Nailik
Nailik merged commit 0a74213 into Nailik:main Sep 3, 2026
3 checks passed
Nailik pushed a commit that referenced this pull request Sep 4, 2026
The platform setups read coordinator.data.device_type to decide which
entities exist. Since #21 the first refresh runs in a background task, so
the data is still None when the platforms are forwarded and binary_sensor,
select and sensor abort with AttributeError.

Forward the platforms from that background task once the first refresh has
produced data, retrying while the device is unreachable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants