diff --git a/esphome/__main__.py b/esphome/__main__.py index a83cbbfeb1..9930119c86 100644 --- a/esphome/__main__.py +++ b/esphome/__main__.py @@ -332,11 +332,10 @@ def upload_program(config, args, host): return 1 # Unknown target platform ota_conf = {} - if ota := config.get(CONF_OTA): - for ota_item in ota: - if ota_item[CONF_PLATFORM] == CONF_ESPHOME: - ota_conf = ota_item - break + for ota_item in config.get(CONF_OTA, []): + if ota_item[CONF_PLATFORM] == CONF_ESPHOME: + ota_conf = ota_item + break if not ota_conf: raise EsphomeError( diff --git a/esphome/cpp_helpers.py b/esphome/cpp_helpers.py index 402f60284e..ce494e5d9d 100644 --- a/esphome/cpp_helpers.py +++ b/esphome/cpp_helpers.py @@ -142,11 +142,10 @@ async def build_registry_list(registry, config): async def past_safe_mode(): ota_conf = {} - if CONF_OTA in CORE.config: - for ota_item in CORE.config.get(CONF_OTA): - if ota_item[CONF_PLATFORM] == CONF_ESPHOME: - ota_conf = ota_item - break + for ota_item in CORE.config.get(CONF_OTA, []): + if ota_item[CONF_PLATFORM] == CONF_ESPHOME: + ota_conf = ota_item + break if not ota_conf: return