Reduce ESPHome reconnect time (#112001)

Use eager tasks to request device_info and entities which avoids
waiting one event loop to send the requests to the device
pull/108513/head
J. Nick Koston 2024-03-01 17:16:01 -10:00 committed by GitHub
parent 8ff2a39238
commit 4249d17c1b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 2 deletions

View File

@ -50,6 +50,7 @@ from homeassistant.helpers.issue_registry import (
from homeassistant.helpers.service import async_set_service_schema
from homeassistant.helpers.template import Template
from homeassistant.helpers.typing import EventType
from homeassistant.util.async_ import create_eager_task
from .bluetooth import async_connect_scanner
from .const import (
@ -390,8 +391,8 @@ class ESPHomeManager:
stored_device_name = entry.data.get(CONF_DEVICE_NAME)
unique_id_is_mac_address = unique_id and ":" in unique_id
results = await asyncio.gather(
cli.device_info(),
cli.list_entities_services(),
create_eager_task(cli.device_info()),
create_eager_task(cli.list_entities_services()),
)
device_info: EsphomeDeviceInfo = results[0]