From b9ed315cf7605b0f89a6f4c8be1c63063557ab31 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 23 Feb 2024 08:35:17 -1000 Subject: [PATCH] Avoid yalexs_ble delaying startup when the lock is not advertising (#111167) --- homeassistant/components/yalexs_ble/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/yalexs_ble/__init__.py b/homeassistant/components/yalexs_ble/__init__.py index 9d2679d79d3..5082029af29 100644 --- a/homeassistant/components/yalexs_ble/__init__.py +++ b/homeassistant/components/yalexs_ble/__init__.py @@ -15,7 +15,7 @@ from yalexs_ble import ( from homeassistant.components import bluetooth from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_ADDRESS, EVENT_HOMEASSISTANT_STOP, Platform -from homeassistant.core import CALLBACK_TYPE, Event, HomeAssistant, callback +from homeassistant.core import CALLBACK_TYPE, CoreState, Event, HomeAssistant, callback from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady from .const import ( @@ -73,6 +73,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: # We may already have the advertisement, so check for it. if service_info := async_find_existing_service_info(hass, local_name, address): push_lock.update_advertisement(service_info.device, service_info.advertisement) + elif hass.state is CoreState.starting: + # If we are starting and the advertisement is not found, do not delay + # the setup. We will wait for the advertisement to be found and then + # discovery will trigger setup retry. + raise ConfigEntryNotReady("{local_name} ({address}) not advertising yet") entry.async_on_unload( bluetooth.async_register_callback(