mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Avoid yalexs_ble delaying startup when the lock is not advertising (#111167)
This commit is contained in:
parent
b6b5b1f788
commit
b9ed315cf7
@ -15,7 +15,7 @@ from yalexs_ble import (
|
|||||||
from homeassistant.components import bluetooth
|
from homeassistant.components import bluetooth
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_ADDRESS, EVENT_HOMEASSISTANT_STOP, Platform
|
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 homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
|
||||||
|
|
||||||
from .const import (
|
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.
|
# We may already have the advertisement, so check for it.
|
||||||
if service_info := async_find_existing_service_info(hass, local_name, address):
|
if service_info := async_find_existing_service_info(hass, local_name, address):
|
||||||
push_lock.update_advertisement(service_info.device, service_info.advertisement)
|
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(
|
entry.async_on_unload(
|
||||||
bluetooth.async_register_callback(
|
bluetooth.async_register_callback(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user