Avoid yalexs_ble delaying startup when the lock is not advertising (#111167)
This commit is contained in:
parent
b6b5b1f788
commit
b9ed315cf7
1 changed files with 6 additions and 1 deletions
|
@ -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(
|
||||
|
|
Loading…
Add table
Reference in a new issue