From e7c1ddb4525031c90df0e76414cae81577d9d953 Mon Sep 17 00:00:00 2001
From: Matt Quigley <quigleymd+github@gmail.com>
Date: Sun, 28 Apr 2024 14:57:11 -0500
Subject: [PATCH] patch esphome cli to skip mqtt based device discovery if
 --device option is specified (#6371)

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
---
 esphome/__main__.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/esphome/__main__.py b/esphome/__main__.py
index b461dda4e7..54c1aa112a 100644
--- a/esphome/__main__.py
+++ b/esphome/__main__.py
@@ -343,9 +343,10 @@ def upload_program(config, args, host):
     password = ota_conf.get(CONF_PASSWORD, "")
 
     if (
-        not is_ip_address(CORE.address)
+        not is_ip_address(CORE.address)  # pylint: disable=too-many-boolean-expressions
         and (get_port_type(host) == "MQTT" or config[CONF_MDNS][CONF_DISABLED])
         and CONF_MQTT in config
+        and (not args.device or args.device == "MQTT")
     ):
         from esphome import mqtt