mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 03:37: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,
|
APIConnectionError,
|
||||||
APIIntEnum,
|
APIIntEnum,
|
||||||
APIVersion,
|
APIVersion,
|
||||||
|
BadNameAPIError,
|
||||||
DeviceInfo as EsphomeDeviceInfo,
|
DeviceInfo as EsphomeDeviceInfo,
|
||||||
EntityCategory as EsphomeEntityCategory,
|
EntityCategory as EsphomeEntityCategory,
|
||||||
EntityInfo,
|
EntityInfo,
|
||||||
@ -269,6 +270,7 @@ async def async_setup_entry( # noqa: C901
|
|||||||
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:
|
if entry_data.device_info.name:
|
||||||
|
cli.expected_name = entry_data.device_info.name
|
||||||
reconnect_logic.name = 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
|
||||||
@ -300,6 +302,12 @@ async def async_setup_entry( # noqa: C901
|
|||||||
"""Start reauth flow if appropriate connect error type."""
|
"""Start reauth flow if appropriate connect error type."""
|
||||||
if isinstance(err, (RequiresEncryptionAPIError, InvalidEncryptionKeyAPIError)):
|
if isinstance(err, (RequiresEncryptionAPIError, InvalidEncryptionKeyAPIError)):
|
||||||
entry.async_start_reauth(hass)
|
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(
|
reconnect_logic = ReconnectLogic(
|
||||||
client=cli,
|
client=cli,
|
||||||
@ -317,6 +325,7 @@ async def async_setup_entry( # noqa: C901
|
|||||||
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:
|
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
|
reconnect_logic.name = entry_data.device_info.name
|
||||||
|
|
||||||
await reconnect_logic.start()
|
await reconnect_logic.start()
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
"name": "ESPHome",
|
"name": "ESPHome",
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://www.home-assistant.io/integrations/esphome",
|
"documentation": "https://www.home-assistant.io/integrations/esphome",
|
||||||
"requirements": ["aioesphomeapi==10.7.0"],
|
"requirements": ["aioesphomeapi==10.8.1"],
|
||||||
"zeroconf": ["_esphomelib._tcp.local."],
|
"zeroconf": ["_esphomelib._tcp.local."],
|
||||||
"codeowners": ["@OttoWinter", "@jesserockz"],
|
"codeowners": ["@OttoWinter", "@jesserockz"],
|
||||||
"after_dependencies": ["zeroconf", "tag"],
|
"after_dependencies": ["zeroconf", "tag"],
|
||||||
|
@ -166,7 +166,7 @@ aioeagle==1.1.0
|
|||||||
aioemonitor==1.0.5
|
aioemonitor==1.0.5
|
||||||
|
|
||||||
# homeassistant.components.esphome
|
# homeassistant.components.esphome
|
||||||
aioesphomeapi==10.7.0
|
aioesphomeapi==10.8.1
|
||||||
|
|
||||||
# homeassistant.components.flo
|
# homeassistant.components.flo
|
||||||
aioflo==2021.11.0
|
aioflo==2021.11.0
|
||||||
|
@ -119,7 +119,7 @@ aioeagle==1.1.0
|
|||||||
aioemonitor==1.0.5
|
aioemonitor==1.0.5
|
||||||
|
|
||||||
# homeassistant.components.esphome
|
# homeassistant.components.esphome
|
||||||
aioesphomeapi==10.7.0
|
aioesphomeapi==10.8.1
|
||||||
|
|
||||||
# homeassistant.components.flo
|
# homeassistant.components.flo
|
||||||
aioflo==2021.11.0
|
aioflo==2021.11.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user