Fix ESPHome ReconnectLogic to make faster connection when device comes online (#64697)

pull/64787/head
Jesse Hills 2022-01-24 08:14:17 +13:00 committed by GitHub
parent d5ec2fe842
commit 8736b0649b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -108,7 +108,9 @@ class DomainData:
return ret
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
async def async_setup_entry( # noqa: C901
hass: HomeAssistant, entry: ConfigEntry
) -> bool:
"""Set up the esphome component."""
host = entry.data[CONF_HOST]
port = entry.data[CONF_PORT]
@ -266,6 +268,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
assert cli.api_version is not None
entry_data.api_version = cli.api_version
entry_data.available = True
if entry_data.device_info.name:
reconnect_logic.name = entry_data.device_info.name
device_id = _async_setup_device_registry(
hass, entry, entry_data.device_info
)
@ -312,6 +316,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
await entry_data.async_update_static_infos(hass, entry, infos)
await _setup_services(hass, entry_data, services)
if entry_data.device_info is not None and entry_data.device_info.name:
reconnect_logic.name = entry_data.device_info.name
await reconnect_logic.start()
entry_data.cleanup_callbacks.append(reconnect_logic.stop_callback)