Fix display of update state in webinterfae (#7045)

Co-authored-by: Leo Schelvis <leo.schelvis@gmail.com>
This commit is contained in:
leejoow 2024-07-06 06:57:30 +02:00 committed by GitHub
parent 6ca7b30f75
commit dd1e480142
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 10 deletions

View file

@ -116,19 +116,18 @@ void HttpRequestUpdate::update() {
} }
} }
std::string current_version = this->current_version_; std::string current_version;
if (current_version.empty()) {
#ifdef ESPHOME_PROJECT_VERSION #ifdef ESPHOME_PROJECT_VERSION
current_version = ESPHOME_PROJECT_VERSION; current_version = ESPHOME_PROJECT_VERSION;
#else #else
current_version = ESPHOME_VERSION; current_version = ESPHOME_VERSION;
#endif #endif
}
this->update_info_.current_version = current_version; 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; this->state_ = update::UPDATE_STATE_NO_UPDATE;
} else if (this->update_info_.latest_version != this->current_version_) { } else {
this->state_ = update::UPDATE_STATE_AVAILABLE; this->state_ = update::UPDATE_STATE_AVAILABLE;
} }

View file

@ -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_request_parent(HttpRequestComponent *request_parent) { this->request_parent_ = request_parent; }
void set_ota_parent(OtaHttpRequestComponent *ota_parent) { this->ota_parent_ = ota_parent; } void set_ota_parent(OtaHttpRequestComponent *ota_parent) { this->ota_parent_ = ota_parent; }
void set_current_version(const std::string &current_version) { this->current_version_ = current_version; }
float get_setup_priority() const override { return setup_priority::AFTER_WIFI; } float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
protected: protected:
HttpRequestComponent *request_parent_; HttpRequestComponent *request_parent_;
OtaHttpRequestComponent *ota_parent_; OtaHttpRequestComponent *ota_parent_;
std::string source_url_; std::string source_url_;
std::string current_version_{""};
}; };
} // namespace http_request } // namespace http_request