mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 19:57:07 +00:00
ESPHome prevent connecting to different hosts when IP reassigned (#64559)
This commit is contained in:
parent
eb48748038
commit
a65a0b5903
@ -13,6 +13,7 @@ from aioesphomeapi import (
|
||||
APIConnectionError,
|
||||
APIIntEnum,
|
||||
APIVersion,
|
||||
BadNameAPIError,
|
||||
DeviceInfo as EsphomeDeviceInfo,
|
||||
EntityCategory as EsphomeEntityCategory,
|
||||
EntityInfo,
|
||||
@ -269,6 +270,7 @@ async def async_setup_entry( # noqa: C901
|
||||
entry_data.api_version = cli.api_version
|
||||
entry_data.available = True
|
||||
if entry_data.device_info.name:
|
||||
cli.expected_name = 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
|
||||
@ -300,6 +302,12 @@ async def async_setup_entry( # noqa: C901
|
||||
"""Start reauth flow if appropriate connect error type."""
|
||||
if isinstance(err, (RequiresEncryptionAPIError, InvalidEncryptionKeyAPIError)):
|
||||
entry.async_start_reauth(hass)
|
||||
if isinstance(err, BadNameAPIError):
|
||||
_LOGGER.warning(
|
||||
"Name of device %s changed to %s, potentially due to IP reassignment",
|
||||
cli.expected_name,
|
||||
err.received_name,
|
||||
)
|
||||
|
||||
reconnect_logic = ReconnectLogic(
|
||||
client=cli,
|
||||
@ -317,6 +325,7 @@ async def async_setup_entry( # noqa: C901
|
||||
await _setup_services(hass, entry_data, services)
|
||||
|
||||
if entry_data.device_info is not None and entry_data.device_info.name:
|
||||
cli.expected_name = entry_data.device_info.name
|
||||
reconnect_logic.name = entry_data.device_info.name
|
||||
|
||||
await reconnect_logic.start()
|
||||
|
@ -3,7 +3,7 @@
|
||||
"name": "ESPHome",
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/esphome",
|
||||
"requirements": ["aioesphomeapi==10.7.0"],
|
||||
"requirements": ["aioesphomeapi==10.8.1"],
|
||||
"zeroconf": ["_esphomelib._tcp.local."],
|
||||
"codeowners": ["@OttoWinter", "@jesserockz"],
|
||||
"after_dependencies": ["zeroconf", "tag"],
|
||||
|
@ -166,7 +166,7 @@ aioeagle==1.1.0
|
||||
aioemonitor==1.0.5
|
||||
|
||||
# homeassistant.components.esphome
|
||||
aioesphomeapi==10.7.0
|
||||
aioesphomeapi==10.8.1
|
||||
|
||||
# homeassistant.components.flo
|
||||
aioflo==2021.11.0
|
||||
|
@ -119,7 +119,7 @@ aioeagle==1.1.0
|
||||
aioemonitor==1.0.5
|
||||
|
||||
# homeassistant.components.esphome
|
||||
aioesphomeapi==10.7.0
|
||||
aioesphomeapi==10.8.1
|
||||
|
||||
# homeassistant.components.flo
|
||||
aioflo==2021.11.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user