ESPHome
2026.6.0-dev
Loading...
Searching...
No Matches
esphome
components
update
update_entity.cpp
Go to the documentation of this file.
1
#include "
update_entity.h
"
2
#include "
esphome/core/defines.h
"
3
#include "
esphome/core/controller_registry.h
"
4
#include "
esphome/core/log.h
"
5
#include "
esphome/core/progmem.h
"
6
7
namespace
esphome::update
{
8
9
static
const
char
*
const
TAG
=
"update"
;
10
11
// Update state strings indexed by UpdateState enum (0-3): UNKNOWN, NO UPDATE, UPDATE AVAILABLE, INSTALLING
12
PROGMEM_STRING_TABLE
(UpdateStateStrings,
"UNKNOWN"
,
"NO UPDATE"
,
"UPDATE AVAILABLE"
,
"INSTALLING"
);
13
14
const
LogString *
update_state_to_string
(
UpdateState
state
) {
15
return
UpdateStateStrings::get_log_str(
static_cast<
uint8_t
>
(
state
),
16
static_cast<
uint8_t
>
(
UpdateState::UPDATE_STATE_UNKNOWN
));
17
}
18
19
void
UpdateEntity::publish_state
() {
20
ESP_LOGV(TAG,
21
"'%s' >>\n"
22
" Current Version: %s"
,
23
this->
name_
.
c_str
(), this->update_info_.current_version.c_str());
24
25
if
(!this->
update_info_
.
md5
.empty()) {
26
ESP_LOGV(TAG,
" Latest Version: %s"
, this->
update_info_
.
latest_version
.c_str());
27
}
28
if
(!this->
update_info_
.
firmware_url
.empty()) {
29
ESP_LOGV(TAG,
" Firmware URL: %s"
, this->
update_info_
.
firmware_url
.c_str());
30
}
31
32
ESP_LOGV(TAG,
" Title: %s"
, this->
update_info_
.
title
.c_str());
33
if
(!this->
update_info_
.
summary
.empty()) {
34
ESP_LOGV(TAG,
" Summary: %s"
, this->
update_info_
.
summary
.c_str());
35
}
36
if
(!this->
update_info_
.
release_url
.empty()) {
37
ESP_LOGV(TAG,
" Release URL: %s"
, this->
update_info_
.
release_url
.c_str());
38
}
39
40
if
(this->
update_info_
.
has_progress
) {
41
ESP_LOGV(TAG,
" Progress: %.0f%%"
, this->
update_info_
.
progress
);
42
}
43
44
this->
set_has_state
(
true
);
45
this->
state_callback_
.call();
46
#if defined(USE_UPDATE) && defined(USE_CONTROLLER_REGISTRY)
47
ControllerRegistry::notify_update(
this
);
48
#endif
49
}
50
51
}
// namespace esphome::update
esphome::EntityBase::name_
StringRef name_
Definition
entity_base.h:260
esphome::EntityBase::set_has_state
void set_has_state(bool state)
Definition
entity_base.h:194
esphome::StringRef::c_str
constexpr const char * c_str() const
Definition
string_ref.h:73
esphome::update::UpdateEntity::publish_state
void publish_state()
Definition
update_entity.cpp:19
esphome::update::UpdateEntity::update_info_
UpdateInfo update_info_
Definition
update_entity.h:54
esphome::update::UpdateEntity::state_callback_
LazyCallbackManager< void()> state_callback_
Definition
update_entity.h:56
controller_registry.h
defines.h
state
bool state
Definition
fan.h:2
log.h
esphome::spi::TAG
const char *const TAG
Definition
spi.cpp:7
esphome::update
Definition
automation.h:7
esphome::update::UpdateState
UpdateState
Definition
update_entity.h:22
esphome::update::UPDATE_STATE_UNKNOWN
@ UPDATE_STATE_UNKNOWN
Definition
update_entity.h:23
esphome::update::update_state_to_string
const LogString * update_state_to_string(UpdateState state)
Definition
update_entity.cpp:14
esphome::update::PROGMEM_STRING_TABLE
PROGMEM_STRING_TABLE(UpdateStateStrings, "UNKNOWN", "NO UPDATE", "UPDATE AVAILABLE", "INSTALLING")
progmem.h
esphome::update::UpdateInfo::md5
std::string md5
Definition
update_entity.h:17
esphome::update::UpdateInfo::firmware_url
std::string firmware_url
Definition
update_entity.h:16
esphome::update::UpdateInfo::release_url
std::string release_url
Definition
update_entity.h:15
esphome::update::UpdateInfo::title
std::string title
Definition
update_entity.h:13
esphome::update::UpdateInfo::summary
std::string summary
Definition
update_entity.h:14
esphome::update::UpdateInfo::latest_version
std::string latest_version
Definition
update_entity.h:11
esphome::update::UpdateInfo::has_progress
bool has_progress
Definition
update_entity.h:18
esphome::update::UpdateInfo::progress
float progress
Definition
update_entity.h:19
update_entity.h
Generated by
1.12.0