mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 10:17:09 +00:00
Fix ESPHome ReconnectLogic to make faster connection when device comes online (#64697)
This commit is contained in:
parent
d5ec2fe842
commit
8736b0649b
@ -108,7 +108,9 @@ class DomainData:
|
|||||||
return ret
|
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."""
|
"""Set up the esphome component."""
|
||||||
host = entry.data[CONF_HOST]
|
host = entry.data[CONF_HOST]
|
||||||
port = entry.data[CONF_PORT]
|
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
|
assert cli.api_version is not None
|
||||||
entry_data.api_version = cli.api_version
|
entry_data.api_version = cli.api_version
|
||||||
entry_data.available = True
|
entry_data.available = True
|
||||||
|
if entry_data.device_info.name:
|
||||||
|
reconnect_logic.name = entry_data.device_info.name
|
||||||
device_id = _async_setup_device_registry(
|
device_id = _async_setup_device_registry(
|
||||||
hass, entry, entry_data.device_info
|
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 entry_data.async_update_static_infos(hass, entry, infos)
|
||||||
await _setup_services(hass, entry_data, services)
|
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()
|
await reconnect_logic.start()
|
||||||
entry_data.cleanup_callbacks.append(reconnect_logic.stop_callback)
|
entry_data.cleanup_callbacks.append(reconnect_logic.stop_callback)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user