mirror of
				https://github.com/esphome/esphome.git
				synced 2025-11-04 09:01:49 +00:00 
			
		
		
		
	[dashboard] Fix port fallback regression when device is offline
This commit is contained in:
		@@ -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)
 | 
				
			||||||
        ]
 | 
					        ]
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user