1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-30 14:43:51 +00:00

Merge branch 'port_fallback' into integration

This commit is contained in:
J. Nick Koston
2025-08-08 16:05:20 -05:00

View File

@@ -324,14 +324,13 @@ class EsphomePortCommandWebSocket(EsphomeCommandWebSocket):
configuration = json_message["configuration"] configuration = json_message["configuration"]
config_file = settings.rel_path(configuration) config_file = settings.rel_path(configuration)
port = json_message["port"] port = json_message["port"]
addresses: list[str] = [port] addresses: list[str] = []
if ( if (
port == "OTA" # pylint: disable=too-many-boolean-expressions port == "OTA" # pylint: disable=too-many-boolean-expressions
and (entry := entries.get(config_file)) and (entry := entries.get(config_file))
and entry.loaded_integrations and entry.loaded_integrations
and "api" in entry.loaded_integrations and "api" in entry.loaded_integrations
): ):
addresses = []
# First priority: entry.address AKA use_address # First priority: entry.address AKA use_address
if ( if (
(use_address := entry.address) (use_address := entry.address)
@@ -359,6 +358,13 @@ class EsphomePortCommandWebSocket(EsphomeCommandWebSocket):
# since MQTT logging will not work otherwise # since MQTT logging will not work otherwise
addresses.extend(sort_ip_addresses(new_addresses)) addresses.extend(sort_ip_addresses(new_addresses))
if not addresses:
# If no address was found, use the port directly
# as otherwise they will get the chooser which
# does not work with the dashboard as there is no
# interactive way to get keyboard input
addresses = [port]
device_args: list[str] = [ device_args: list[str] = [
arg for address in addresses for arg in ("--device", address) arg for address in addresses for arg in ("--device", address)
] ]