Connect esphome ble scanner as soon as possible (#83728)

Other integration depend on it being available so connect
it first
This commit is contained in:
J. Nick Koston 2022-12-10 10:17:05 -10:00 committed by GitHub
parent 642cefb035
commit 9094d73df1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -259,6 +259,12 @@ async def async_setup_entry( # noqa: C901
if entry_data.device_info.name:
cli.expected_name = entry_data.device_info.name
reconnect_logic.name = entry_data.device_info.name
if device_info.bluetooth_proxy_version:
entry_data.disconnect_callbacks.append(
await async_connect_scanner(hass, entry, cli, entry_data)
)
device_id = _async_setup_device_registry(
hass, entry, entry_data.device_info
)
@ -270,10 +276,6 @@ async def async_setup_entry( # noqa: C901
await cli.subscribe_states(entry_data.async_update_state)
await cli.subscribe_service_calls(async_on_service_call)
await cli.subscribe_home_assistant_states(async_on_state_subscription)
if entry_data.device_info.bluetooth_proxy_version:
entry_data.disconnect_callbacks.append(
await async_connect_scanner(hass, entry, cli, entry_data)
)
hass.async_create_task(entry_data.async_save_to_store())
except APIConnectionError as err: