From 214454ff511a2e04be31a5d7b37ac753ab05a02c Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Tue, 15 Apr 2025 06:30:07 +0200 Subject: [PATCH] Fix '--device MQTT' for devices with static IP (#8535) --- esphome/__main__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/esphome/__main__.py b/esphome/__main__.py index 0d9662bfd6..c78eda7e12 100644 --- a/esphome/__main__.py +++ b/esphome/__main__.py @@ -375,10 +375,12 @@ def upload_program(config, args, host): password = ota_conf.get(CONF_PASSWORD, "") if ( - 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 + CONF_MQTT in config # pylint: disable=too-many-boolean-expressions and (not args.device or args.device in ("MQTT", "OTA")) + and ( + ((config[CONF_MDNS][CONF_DISABLED]) and not is_ip_address(CORE.address)) + or get_port_type(host) == "MQTT" + ) ): from esphome import mqtt