From 3f11bb5f62373b85aa6ba735e40c11eb4f458e65 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 15 Nov 2023 03:28:49 -0600 Subject: [PATCH] Speed up connecting to ESPHome devices (#104018) --- homeassistant/components/esphome/manager.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/esphome/manager.py b/homeassistant/components/esphome/manager.py index d2eca7d39f9..62ef1d43a5f 100644 --- a/homeassistant/components/esphome/manager.py +++ b/homeassistant/components/esphome/manager.py @@ -1,6 +1,7 @@ """Manager for esphome devices.""" from __future__ import annotations +import asyncio import logging from typing import TYPE_CHECKING, Any, NamedTuple @@ -454,9 +455,11 @@ class ESPHomeManager: hass, entry, entity_infos, device_info.mac_address ) await _setup_services(hass, entry_data, services) - await cli.subscribe_states(entry_data.async_update_state) - await cli.subscribe_service_calls(self.async_on_service_call) - await cli.subscribe_home_assistant_states(self.async_on_state_subscription) + await asyncio.gather( + cli.subscribe_states(entry_data.async_update_state), + cli.subscribe_service_calls(self.async_on_service_call), + cli.subscribe_home_assistant_states(self.async_on_state_subscription), + ) if device_info.voice_assistant_version: entry_data.disconnect_callbacks.append(