From d6507ce329f0fef53b76fbfcb0bcb3554a9627cc Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 12 Jan 2026 20:55:40 -1000 Subject: [PATCH] [esphome] Fix OTA backend abort not being called on error (#13182) --- esphome/components/esphome/ota/ota_esphome.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/esphome/components/esphome/ota/ota_esphome.cpp b/esphome/components/esphome/ota/ota_esphome.cpp index 6cfd543553..175bc40f81 100644 --- a/esphome/components/esphome/ota/ota_esphome.cpp +++ b/esphome/components/esphome/ota/ota_esphome.cpp @@ -395,12 +395,14 @@ void ESPHomeOTAComponent::handle_data_() { error: this->write_byte_(static_cast(error_code)); - this->cleanup_connection_(); + // Abort backend before cleanup - cleanup_connection_() destroys the backend if (this->backend_ != nullptr && update_started) { this->backend_->abort(); } + this->cleanup_connection_(); + this->status_momentary_error("err", 5000); #ifdef USE_OTA_STATE_CALLBACK this->state_callback_.call(ota::OTA_ERROR, 0.0f, static_cast(error_code));