From dd1e480142ad378e4e93b82fd435da70635de2c4 Mon Sep 17 00:00:00 2001 From: leejoow Date: Sat, 6 Jul 2024 06:57:30 +0200 Subject: [PATCH] Fix display of update state in webinterfae (#7045) Co-authored-by: Leo Schelvis --- .../http_request/update/http_request_update.cpp | 13 ++++++------- .../http_request/update/http_request_update.h | 3 --- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/esphome/components/http_request/update/http_request_update.cpp b/esphome/components/http_request/update/http_request_update.cpp index 98129e59dc..0a14dfd933 100644 --- a/esphome/components/http_request/update/http_request_update.cpp +++ b/esphome/components/http_request/update/http_request_update.cpp @@ -116,19 +116,18 @@ void HttpRequestUpdate::update() { } } - std::string current_version = this->current_version_; - if (current_version.empty()) { + std::string current_version; #ifdef ESPHOME_PROJECT_VERSION - current_version = ESPHOME_PROJECT_VERSION; + current_version = ESPHOME_PROJECT_VERSION; #else - current_version = ESPHOME_VERSION; + current_version = ESPHOME_VERSION; #endif - } + this->update_info_.current_version = current_version; - if (this->update_info_.latest_version.empty()) { + if (this->update_info_.latest_version.empty() || this->update_info_.latest_version == update_info_.current_version) { this->state_ = update::UPDATE_STATE_NO_UPDATE; - } else if (this->update_info_.latest_version != this->current_version_) { + } else { this->state_ = update::UPDATE_STATE_AVAILABLE; } diff --git a/esphome/components/http_request/update/http_request_update.h b/esphome/components/http_request/update/http_request_update.h index 1337822ecc..a6bc97392b 100644 --- a/esphome/components/http_request/update/http_request_update.h +++ b/esphome/components/http_request/update/http_request_update.h @@ -22,15 +22,12 @@ class HttpRequestUpdate : public update::UpdateEntity, public PollingComponent { void set_request_parent(HttpRequestComponent *request_parent) { this->request_parent_ = request_parent; } void set_ota_parent(OtaHttpRequestComponent *ota_parent) { this->ota_parent_ = ota_parent; } - void set_current_version(const std::string ¤t_version) { this->current_version_ = current_version; } - float get_setup_priority() const override { return setup_priority::AFTER_WIFI; } protected: HttpRequestComponent *request_parent_; OtaHttpRequestComponent *ota_parent_; std::string source_url_; - std::string current_version_{""}; }; } // namespace http_request