mirror of
https://github.com/esphome/esphome.git
synced 2026-10-07 03:16:37 +00:00
[update] Move update_state_to_string to update component and convert to PROGMEM_STRING_TABLE (#13796)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
co-authored by
Copilot
parent
b7dc975331
commit
368ef5687b
@@ -29,6 +29,10 @@
|
||||
#include "esphome/components/climate/climate.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_UPDATE
|
||||
#include "esphome/components/update/update_entity.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_WATER_HEATER
|
||||
#include "esphome/components/water_heater/water_heater.h"
|
||||
#endif
|
||||
@@ -2104,19 +2108,6 @@ std::string WebServer::event_json_(event::Event *obj, StringRef event_type, Json
|
||||
#endif
|
||||
|
||||
#ifdef USE_UPDATE
|
||||
static const LogString *update_state_to_string(update::UpdateState state) {
|
||||
switch (state) {
|
||||
case update::UPDATE_STATE_NO_UPDATE:
|
||||
return LOG_STR("NO UPDATE");
|
||||
case update::UPDATE_STATE_AVAILABLE:
|
||||
return LOG_STR("UPDATE AVAILABLE");
|
||||
case update::UPDATE_STATE_INSTALLING:
|
||||
return LOG_STR("INSTALLING");
|
||||
default:
|
||||
return LOG_STR("UNKNOWN");
|
||||
}
|
||||
}
|
||||
|
||||
void WebServer::on_update(update::UpdateEntity *obj) {
|
||||
this->events_.deferrable_send_state(obj, "state", update_state_json_generator);
|
||||
}
|
||||
@@ -2158,7 +2149,7 @@ std::string WebServer::update_json_(update::UpdateEntity *obj, JsonDetail start_
|
||||
JsonObject root = builder.root();
|
||||
|
||||
char buf[PSTR_LOCAL_SIZE];
|
||||
set_json_icon_state_value(root, obj, "update", PSTR_LOCAL(update_state_to_string(obj->state)),
|
||||
set_json_icon_state_value(root, obj, "update", PSTR_LOCAL(update::update_state_to_string(obj->state)),
|
||||
obj->update_info.latest_version, start_config);
|
||||
if (start_config == DETAIL_ALL) {
|
||||
root[ESPHOME_F("current_version")] = obj->update_info.current_version;
|
||||
|
||||
Reference in New Issue
Block a user