ESPHome 2026.3.0-dev
Loading...
Searching...
No Matches
update_entity.cpp
Go to the documentation of this file.
1#include "update_entity.h"
4#include "esphome/core/log.h"
6
7namespace esphome {
8namespace update {
9
10static const char *const TAG = "update";
11
12// Update state strings indexed by UpdateState enum (0-3): UNKNOWN, NO UPDATE, UPDATE AVAILABLE, INSTALLING
13PROGMEM_STRING_TABLE(UpdateStateStrings, "UNKNOWN", "NO UPDATE", "UPDATE AVAILABLE", "INSTALLING");
14
16 return UpdateStateStrings::get_log_str(static_cast<uint8_t>(state),
17 static_cast<uint8_t>(UpdateState::UPDATE_STATE_UNKNOWN));
18}
19
21 ESP_LOGD(TAG,
22 "'%s' >>\n"
23 " Current Version: %s",
24 this->name_.c_str(), this->update_info_.current_version.c_str());
25
26 if (!this->update_info_.md5.empty()) {
27 ESP_LOGD(TAG, " Latest Version: %s", this->update_info_.latest_version.c_str());
28 }
29 if (!this->update_info_.firmware_url.empty()) {
30 ESP_LOGD(TAG, " Firmware URL: %s", this->update_info_.firmware_url.c_str());
31 }
32
33 ESP_LOGD(TAG, " Title: %s", this->update_info_.title.c_str());
34 if (!this->update_info_.summary.empty()) {
35 ESP_LOGD(TAG, " Summary: %s", this->update_info_.summary.c_str());
36 }
37 if (!this->update_info_.release_url.empty()) {
38 ESP_LOGD(TAG, " Release URL: %s", this->update_info_.release_url.c_str());
39 }
40
41 if (this->update_info_.has_progress) {
42 ESP_LOGD(TAG, " Progress: %.0f%%", this->update_info_.progress);
43 }
44
45 this->set_has_state(true);
46 this->state_callback_.call();
47#if defined(USE_UPDATE) && defined(USE_CONTROLLER_REGISTRY)
49#endif
50}
51
52} // namespace update
53} // namespace esphome
static void notify_update(update::UpdateEntity *obj)
void set_has_state(bool state)
constexpr const char * c_str() const
Definition string_ref.h:73
LazyCallbackManager< void()> state_callback_
bool state
Definition fan.h:2
const char *const TAG
Definition spi.cpp:7
const LogString * update_state_to_string(UpdateState state)
PROGMEM_STRING_TABLE(UpdateStateStrings, "UNKNOWN", "NO UPDATE", "UPDATE AVAILABLE", "INSTALLING")
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7