Fix delay setting up new Yale Access Bluetooth entries (#83683)

Entries took a while to setup because of the
async_wait_init_flow_finish call in _async_setup_component

The delay was so long that users thought the integration
was broken

We had a wait in place for advertisements to arrive
during discovery in case the lock was not
yet seen.  Since integration discovery is deferred
until after startup this wait it no longer needed
This commit is contained in:
J. Nick Koston
2022-12-11 13:55:23 -05:00
committed by Paulus Schoutsen
parent d8982116fb
commit 3a2fb402a4
3 changed files with 23 additions and 44 deletions
+18 -18
View File
@@ -400,8 +400,8 @@ async def test_bluetooth_step_success(hass: HomeAssistant) -> None:
async def test_integration_discovery_success(hass: HomeAssistant) -> None:
"""Test integration discovery step success path."""
with patch(
"homeassistant.components.yalexs_ble.util.async_process_advertisements",
return_value=YALE_ACCESS_LOCK_DISCOVERY_INFO,
"homeassistant.components.yalexs_ble.util.async_discovered_service_info",
return_value=[YALE_ACCESS_LOCK_DISCOVERY_INFO],
):
result = await hass.config_entries.flow.async_init(
DOMAIN,
@@ -443,8 +443,8 @@ async def test_integration_discovery_success(hass: HomeAssistant) -> None:
async def test_integration_discovery_device_not_found(hass: HomeAssistant) -> None:
"""Test integration discovery when the device is not found."""
with patch(
"homeassistant.components.yalexs_ble.util.async_process_advertisements",
side_effect=asyncio.TimeoutError,
"homeassistant.components.yalexs_ble.util.async_discovered_service_info",
return_value=[],
):
result = await hass.config_entries.flow.async_init(
DOMAIN,
@@ -483,8 +483,8 @@ async def test_integration_discovery_takes_precedence_over_bluetooth(
assert flows[0]["context"]["local_name"] == YALE_ACCESS_LOCK_DISCOVERY_INFO.name
with patch(
"homeassistant.components.yalexs_ble.util.async_process_advertisements",
return_value=YALE_ACCESS_LOCK_DISCOVERY_INFO,
"homeassistant.components.yalexs_ble.util.async_discovered_service_info",
return_value=[YALE_ACCESS_LOCK_DISCOVERY_INFO],
):
result = await hass.config_entries.flow.async_init(
DOMAIN,
@@ -558,8 +558,8 @@ async def test_integration_discovery_updates_key_unique_local_name(
entry.add_to_hass(hass)
with patch(
"homeassistant.components.yalexs_ble.util.async_process_advertisements",
return_value=LOCK_DISCOVERY_INFO_UUID_ADDRESS,
"homeassistant.components.yalexs_ble.util.async_discovered_service_info",
return_value=[LOCK_DISCOVERY_INFO_UUID_ADDRESS],
), patch(
"homeassistant.components.yalexs_ble.async_setup_entry",
return_value=True,
@@ -600,8 +600,8 @@ async def test_integration_discovery_updates_key_without_unique_local_name(
entry.add_to_hass(hass)
with patch(
"homeassistant.components.yalexs_ble.util.async_process_advertisements",
return_value=LOCK_DISCOVERY_INFO_UUID_ADDRESS,
"homeassistant.components.yalexs_ble.util.async_discovered_service_info",
return_value=[LOCK_DISCOVERY_INFO_UUID_ADDRESS],
):
result = await hass.config_entries.flow.async_init(
DOMAIN,
@@ -649,8 +649,8 @@ async def test_integration_discovery_updates_key_duplicate_local_name(
entry2.add_to_hass(hass)
with patch(
"homeassistant.components.yalexs_ble.util.async_process_advertisements",
return_value=LOCK_DISCOVERY_INFO_UUID_ADDRESS,
"homeassistant.components.yalexs_ble.util.async_discovered_service_info",
return_value=[LOCK_DISCOVERY_INFO_UUID_ADDRESS],
):
result = await hass.config_entries.flow.async_init(
DOMAIN,
@@ -695,8 +695,8 @@ async def test_integration_discovery_takes_precedence_over_bluetooth_uuid_addres
assert flows[0]["context"]["local_name"] == LOCK_DISCOVERY_INFO_UUID_ADDRESS.name
with patch(
"homeassistant.components.yalexs_ble.util.async_process_advertisements",
return_value=LOCK_DISCOVERY_INFO_UUID_ADDRESS,
"homeassistant.components.yalexs_ble.util.async_discovered_service_info",
return_value=[LOCK_DISCOVERY_INFO_UUID_ADDRESS],
):
result = await hass.config_entries.flow.async_init(
DOMAIN,
@@ -775,8 +775,8 @@ async def test_integration_discovery_takes_precedence_over_bluetooth_non_unique_
assert flows[0]["context"]["local_name"] == OLD_FIRMWARE_LOCK_DISCOVERY_INFO.name
with patch(
"homeassistant.components.yalexs_ble.util.async_process_advertisements",
return_value=OLD_FIRMWARE_LOCK_DISCOVERY_INFO,
"homeassistant.components.yalexs_ble.util.async_discovered_service_info",
return_value=[OLD_FIRMWARE_LOCK_DISCOVERY_INFO],
):
result = await hass.config_entries.flow.async_init(
DOMAIN,
@@ -851,8 +851,8 @@ async def test_user_is_setting_up_lock_and_discovery_happens_in_the_middle(
await valdidate_started.wait()
with patch(
"homeassistant.components.yalexs_ble.util.async_process_advertisements",
return_value=LOCK_DISCOVERY_INFO_UUID_ADDRESS,
"homeassistant.components.yalexs_ble.util.async_discovered_service_info",
return_value=[LOCK_DISCOVERY_INFO_UUID_ADDRESS],
):
discovery_result = await hass.config_entries.flow.async_init(
DOMAIN,