Compare commits

...
Author SHA1 Message Date
J. Nick Koston ff323c18aa Merge branch 'dev' into web-server-domain-flash 2026-10-21 14:40:17 -10:00
J. Nick Koston 4617c96895 Merge remote-tracking branch 'origin/dev' into web-server-domain-flash
# Conflicts:
#	esphome/components/web_server/web_server.cpp
#	esphome/core/entity_base.cpp
#	esphome/core/entity_base.h
#	esphome/core/entity_helpers.py
2026-10-21 11:18:56 -10:00
J. Nick Koston 3cbea1ee2d Merge remote-tracking branch 'origin/esp8266-entity-names-flash' into web-server-domain-flash 2026-10-18 22:32:53 -10:00
J. Nick Koston 8b9e27dc3a Merge remote-tracking branch 'origin/dev' into esp8266-entity-names-flash 2026-10-18 22:31:32 -10:00
J. Nick Koston e0f25b9821 [web_server] Keep entity domain strings in flash on ESP8266
The domain passed to set_json_id is now a ProgmemStr from ESPHOME_F, so
the 23 domain literals leave .rodata on ESP8266. Other platforms still
link the literal.
2026-10-18 21:56:40 -10:00
J. Nick Koston 669357990c Merge remote-tracking branch 'origin/dev' into esp8266-entity-names-flash 2026-10-18 07:33:08 -10:00
J. Nick Koston 4a991266b1 Merge remote-tracking branch 'origin/dev' into esp8266-entity-names-flash 2026-10-16 07:10:38 -10:00
J. Nick Koston aff866913c Share the object id hash loop with the flash name path 2026-10-15 15:30:50 -10:00
J. Nick Koston 984dbd616f Merge branch 'dev' of https://github.com/esphome/esphome into esp8266-entity-names-flash
# Conflicts:
#	esphome/core/string_ref.h
#	tests/components/core/test_progmem_string_ref.cpp
2026-10-14 17:40:09 -10:00
J. Nick Koston fe2637356b Merge remote-tracking branch 'origin/api-action-strings-progmem' into esp8266-entity-names-flash 2026-10-14 16:15:04 -10:00
J. Nick Koston 6f7b875844 Merge remote-tracking branch 'origin/dev' into api-action-strings-progmem 2026-10-14 16:14:40 -10:00
J. Nick Koston 52ec1c7ccf Merge remote-tracking branch 'origin/api-action-strings-progmem' into esp8266-entity-names-flash
# Conflicts:
#	esphome/core/string_ref.h
#	tests/components/core/test_progmem_string_ref.cpp
2026-10-14 16:01:49 -10:00
J. Nick Koston ef5b0861f1 Encode Home Assistant action names and data from flash 2026-10-14 15:59:41 -10:00
J. Nick Koston da561e08d6 Keep the RAM short string encode on memcpy; the ESP8266 shared copy moves to #20423 2026-10-14 15:59:41 -10:00
J. Nick Koston c4c19a00e0 Move the entity domain and MQTT log conversions to the stacked PR 2026-10-12 17:27:40 -10:00
J. Nick Koston 522395de11 Read entity names flash-safely in web_server, MQTT and prometheus 2026-10-12 17:19:03 -10:00
J. Nick Koston 39d63a3166 Keep the entity domain log and dump helpers on the flash-safe name accessors 2026-10-12 17:10:33 -10:00
J. Nick Koston 36cfe5c785 Move the component conversions and the get_name() deprecation to a stacked PR 2026-10-12 17:02:29 -10:00
J. Nick Koston d8dd8cf36c Keep the flash object id hash in entity_base and read it with progmem_read_byte 2026-10-12 16:57:20 -10:00
J. Nick Koston 12c35c1545 Compute the object id hash when an external caller passes 0 2026-10-12 16:53:49 -10:00
J. Nick Koston 0e8a3dfb6f Fold dev's ProgmemStringRef struct into the class and share the progmem short string body 2026-10-12 16:53:49 -10:00
J. Nick Koston 65b32731d4 Keep the ESP8266 short string encode on the shared progmem copy 2026-10-12 16:53:23 -10:00
J. Nick Koston 00f8e89f28 Merge remote-tracking branch 'origin/dev' into esp8266-entity-names-flash 2026-10-12 16:49:42 -10:00
J. Nick Koston 9b873e2179 Keep the RAM short string encode on memcpy and drop unused ProgmemStringRef helpers 2026-10-12 16:47:08 -10:00
J. Nick Koston dd495be861 Fold dev's ProgmemStringRef struct into the class 2026-10-12 16:28:37 -10:00
J. Nick Koston a7fdb143cd Merge branch 'dev' into api-action-strings-progmem 2026-10-12 16:02:23 -10:00
J. Nick Koston 5326d1dfe9 Merge remote-tracking branch 'origin/dev' into esp8266-entity-names-flash
# Conflicts:
#	esphome/components/web_server/web_server.cpp
2026-10-11 16:06:33 -10:00
J. Nick Koston ba9705e19b Construct the get_name() copy with placement new 2026-10-11 15:39:22 -10:00
J. Nick Koston 543a818307 Merge remote-tracking branch 'origin/dev' into esp8266-entity-names-flash
# Conflicts:
#	esphome/components/uart/button/uart_button.cpp
#	esphome/components/uart/switch/uart_switch.cpp
2026-10-11 15:36:07 -10:00
J. Nick Koston 229aa22006 Merge remote-tracking branch 'origin/dev' into api-action-strings-progmem
# Conflicts:
#	esphome/components/api/__init__.py
#	tests/component_tests/api/test_action_metadata.py
2026-10-11 15:26:13 -10:00
J. Nick Koston b31bedd464 Merge remote-tracking branch 'origin/dev' into HEAD
# Conflicts:
#	esphome/components/mqtt/mqtt_button.cpp
#	esphome/components/mqtt/mqtt_lock.cpp
#	esphome/components/mqtt/mqtt_switch.cpp
#	esphome/components/mqtt/mqtt_update.cpp
2026-10-09 18:28:52 -10:00
J. Nick Koston 491a2e58d5 Merge remote-tracking branch 'origin/dev' into HEAD 2026-10-09 18:28:25 -10:00
J. Nick Koston c8d331d44b Merge remote-tracking branch 'origin/dev' into esp8266-entity-names-flash
# Conflicts:
#	esphome/components/current_based/current_based_cover.cpp
2026-10-09 09:37:51 -10:00
J. Nick Koston 40ec3067b6 Merge remote-tracking branch 'origin/dev' into api-action-strings-progmem 2026-10-08 22:14:06 -10:00
J. Nick Koston 62f79e007a Merge remote-tracking branch 'origin/dev' into esp8266-entity-names-flash 2026-10-08 22:14:05 -10:00
J. Nick Koston 4497dad959 Keep the inline short string encode off ESP8266 2026-10-08 22:07:35 -10:00
J. Nick Koston b989221c71 Print prometheus names from flash, keep the inline short string encode off ESP8266 2026-10-08 22:07:33 -10:00
J. Nick Koston 096921cddb Keep get_name() working on ESP8266 with a RAM copy made on first use 2026-10-08 22:00:40 -10:00
J. Nick Koston e3d33df379 Share the outlined PROGMEM append for the progmem string dump 2026-10-08 21:44:09 -10:00
J. Nick Koston 47655129e1 Share the outlined PROGMEM append for the progmem string dump 2026-10-08 21:44:06 -10:00
J. Nick Koston c263852df9 Dump progmem strings straight into the dump buffer 2026-10-08 21:34:34 -10:00
J. Nick Koston 40460f3e01 Dump progmem strings straight into the dump buffer, assert the scratch define is gone 2026-10-08 21:34:31 -10:00
J. Nick Koston 8378c935d6 Drop the scratch define assertion from the action metadata test 2026-10-08 20:17:56 -10:00
J. Nick Koston 7c58d26d13 [api] Add encode_progmem_string for progmem string fields
Generated code passes the ProgmemStringRef instead of spelling out the cast.
2026-10-08 20:17:55 -10:00
J. Nick Koston 1fa844a5d2 [api] Add encode_progmem_string for progmem string fields
Generated code passes the ProgmemStringRef instead of spelling out the cast.
2026-10-08 20:17:55 -10:00
J. Nick Koston 7b5a1f9de9 [api] Encode action strings straight from flash
The service name, description and argument strings are progmem fields, so
list entities no longer copies them into a stack scratch buffer, and the
ESP8266 per action string budget goes away.
2026-10-08 20:10:41 -10:00
J. Nick Koston b63b74f236 [api] Allow the progmem option on string fields
Mirrors the helper from the entity names change, so either PR can merge first.
2026-10-08 20:10:41 -10:00
J. Nick Koston 88f7fc7454 Allow progmem on any string field and split the ProgmemStringRef tests
Long or unforced progmem strings encode through encode_progmem_bytes, which
API action strings need. The ProgmemStringRef tests move to their own file.
2026-10-08 20:04:18 -10:00
J. Nick Koston 140488723d Keep get_name() returning a reference off ESP8266
ProgmemStringRef now holds a StringRef, so get_name() and friendly_name_() can
keep returning const StringRef & on other platforms. External components that
return get_name() from a const StringRef & getter would otherwise return a
reference to a temporary. friendly_name_() is deprecated there, not removed.
2026-10-08 19:55:29 -10:00
J. Nick Koston b626711d50 Build the list entities benchmark with the ProgmemStringRef name field 2026-10-08 19:36:01 -10:00
pre-commit-ci-lite[bot] a6cb560e90 apply automatic formatting fixes 2026-10-09 04:36:31 +00:00
J. Nick Koston a721574706 Hash the RAM fallback name directly and share the short string encoder
Only unnamed entities hash at runtime, and their fallback name is in RAM, so
configure_entity_ hashes it before wrapping and named entities keep the codegen
hash; fnv1_hash_object_id_P is no longer needed. On ESP8266 the short string
encoder uses the outlined flash safe copy for RAM strings too.
2026-10-08 18:32:39 -10:00
J. Nick Koston 568934cc91 Drop the remaining entity name copies in mqtt, pid and prometheus
mqtt puts the name into the discovery JSON straight from flash, the pid
autotuner keeps the entity's log name instead of a std::string, and
prometheus prints names and ids without building a std::string per scrape.
2026-10-08 18:22:29 -10:00
J. Nick Koston 13057b7ae3 Type the API progmem name field as ProgmemStringRef
Progmem string fields must take the short encode path, the outlined encode
helper takes a ProgmemStringRef, and the hasher test checks the Python value.
2026-10-08 18:22:29 -10:00
J. Nick Koston b4289aee59 Add a flash safe fnv1_hash_object_id_P()
calc_object_id_() hashes the name in place instead of copying it into a
stack buffer first.
2026-10-08 18:11:36 -10:00
J. Nick Koston 93aecdd435 Deprecate Sprinkler::valve_name() and guard ProgmemStringRef::write_to
valve_name() returned a flash pointer on ESP8266; it now follows get_name():
static_assert there, deprecated elsewhere, with valve_log_name() for logs.
2026-10-08 17:58:37 -10:00
J. Nick Koston afac871938 [api] Encode entity names straight from flash
Extend the progmem proto option to string fields and mark the entity info
name field with it, so ListEntities copies the name once instead of through
a stack buffer.
2026-10-08 17:58:37 -10:00
J. Nick Koston 4c6e6b5447 Move flash copy and compare into ProgmemStringRef
ProgmemStringRef owns write_to() and equals() with the platform split, so the
EntityBase accessors are inline forwarders. Adds ESPHOME_ENTITY_NAME_MAX_LEN
mirroring NAME_MAX_LENGTH and tidies the codegen and tests.
2026-10-08 17:44:53 -10:00
J. Nick Koston b5c06efb2f Store entity names as ProgmemStringRef and deprecate its c_str()
ProgmemStringRef has no byte-reading operations, so new comparisons or copies
of name_ fail to compile. c_str() stays for external log-only users and is
deprecated until 2027.5.0; in-tree logs now use get_log_name().
2026-10-08 17:37:28 -10:00
J. Nick Koston 5cbdf26993 Tidy comments and always wrap entity names in ESPHOME_PSTR 2026-10-08 17:21:11 -10:00
J. Nick Koston 6f5108eb70 Apply review cleanups and deprecate get_name() off ESP8266
Inline get_name_to() off ESP8266, add write_name_to() and name_equals() so
web_server avoids copies, always emit ESPHOME_PSTR, and follow the get_icon()
pattern: get_name() is a static_assert stub on ESP8266 and ESPDEPRECATED
elsewhere until 2027.5.0.
2026-10-08 17:18:00 -10:00
J. Nick Koston 4ef86fe534 [core] Keep entity names in flash on ESP8266
On ESP8266 codegen emits entity names with PSTR and EntityBase::get_name()
is removed there. get_name_to() copies the name into a caller buffer and
get_log_name() returns it for %s log arguments; both exist on every platform.
2026-10-08 16:57:25 -10:00
+34 -32
View File
@@ -614,8 +614,9 @@ void WebServer::handle_js_request(AsyncWebServerRequest *request) {
// Helper functions to reduce code size by avoiding macro expansion
// Build unique id as: {domain}/{device_name}/{entity_name} or {domain}/{entity_name}
// Uses names (not object_id) to avoid UTF-8 collision issues
static void set_json_id(JsonObject root, EntityBase *obj, const char *prefix, JsonDetail start_config) {
size_t prefix_len = strlen(prefix);
static void set_json_id(JsonObject root, EntityBase *obj, ProgmemStr prefix, JsonDetail start_config) {
const char *prefix_p = reinterpret_cast<const char *>(prefix); // in flash on ESP8266
size_t prefix_len = ESPHOME_strlen_P(prefix_p);
#ifdef USE_DEVICES
Device *device = obj->get_device();
@@ -634,7 +635,7 @@ static void set_json_id(JsonObject root, EntityBase *obj, const char *prefix, Js
static constexpr size_t ID_BUF_SIZE = ESPHOME_DOMAIN_MAX_LEN + 1 + ESPHOME_FRIENDLY_NAME_MAX_LEN + 1;
#endif
char id_buf[ID_BUF_SIZE];
memcpy(id_buf, prefix, prefix_len); // NOLINT(bugprone-not-null-terminated-result)
progmem_memcpy(id_buf, prefix_p, prefix_len);
char *p = id_buf + prefix_len;
*p++ = '/';
@@ -652,7 +653,7 @@ static void set_json_id(JsonObject root, EntityBase *obj, const char *prefix, Js
root[ESPHOME_F("id")] = static_cast<const char *>(id_buf);
if (start_config == DETAIL_ALL) {
root[ESPHOME_F("domain")] = linked(prefix, prefix_len);
root[ESPHOME_F("domain")] = linked(prefix);
#ifdef USE_ESP8266
root[ESPHOME_F("name")] = name; // in id_buf on the stack, so copied
#else
@@ -677,13 +678,13 @@ static void set_json_id(JsonObject root, EntityBase *obj, const char *prefix, Js
// Keep as separate function even though only used once: reduces code size by ~48 bytes
// by allowing compiler to share code between template instantiations (bool, float, etc.)
template<typename T>
static void set_json_value(JsonObject root, EntityBase *obj, const char *prefix, T value, JsonDetail start_config) {
static void set_json_value(JsonObject root, EntityBase *obj, ProgmemStr prefix, T value, JsonDetail start_config) {
set_json_id(root, obj, prefix, start_config);
root[ESPHOME_F("value")] = value;
}
template<typename S, typename T>
static void set_json_icon_state_value(JsonObject root, EntityBase *obj, const char *prefix, S state, T value,
static void set_json_icon_state_value(JsonObject root, EntityBase *obj, ProgmemStr prefix, S state, T value,
JsonDetail start_config) {
set_json_value(root, obj, prefix, value, start_config);
root[ESPHOME_F("state")] = state;
@@ -731,7 +732,7 @@ void WebServer::sensor_json_(sensor::Sensor *obj, float value, JsonDetail start_
const char *state = std::isnan(value)
? "NA"
: (value_accuracy_with_uom_to_buf(buf, value, obj->get_accuracy_decimals(), uom_ref), buf);
set_json_icon_state_value(root, obj, "sensor", state, value, start_config);
set_json_icon_state_value(root, obj, ESPHOME_F("sensor"), state, value, start_config);
if (start_config == DETAIL_ALL) {
this->add_sorting_info_(root, obj);
if (!uom_ref.empty())
@@ -774,7 +775,7 @@ void WebServer::text_sensor_json_(text_sensor::TextSensor *obj, const std::strin
// Not linked: the main loop can rewrite the state before the document is serialized
const JsonString state(value.c_str(), value.size());
set_json_icon_state_value(root, obj, "text_sensor", state, state, start_config);
set_json_icon_state_value(root, obj, ESPHOME_F("text_sensor"), state, state, start_config);
if (start_config == DETAIL_ALL) {
this->add_sorting_info_(root, obj);
}
@@ -844,7 +845,7 @@ void WebServer::switch_all_json_generator(WebServer *web_server, void *source, j
void WebServer::switch_json_(switch_::Switch *obj, bool value, JsonDetail start_config, json::JsonBuilder &builder) {
JsonObject root = builder.root();
set_json_icon_state_value(root, obj, "switch", value ? "ON" : "OFF", value, start_config);
set_json_icon_state_value(root, obj, ESPHOME_F("switch"), value ? "ON" : "OFF", value, start_config);
if (start_config == DETAIL_ALL) {
root[ESPHOME_F("assumed_state")] = obj->assumed_state();
this->add_sorting_info_(root, obj);
@@ -880,7 +881,7 @@ void WebServer::button_all_json_generator(WebServer *web_server, void *source, j
void WebServer::button_json_(button::Button *obj, JsonDetail start_config, json::JsonBuilder &builder) {
JsonObject root = builder.root();
set_json_id(root, obj, "button", start_config);
set_json_id(root, obj, ESPHOME_F("button"), start_config);
if (start_config == DETAIL_ALL) {
this->add_sorting_info_(root, obj);
}
@@ -919,7 +920,7 @@ void WebServer::binary_sensor_json_(binary_sensor::BinarySensor *obj, bool value
json::JsonBuilder &builder) {
JsonObject root = builder.root();
set_json_icon_state_value(root, obj, "binary_sensor", value ? "ON" : "OFF", value, start_config);
set_json_icon_state_value(root, obj, ESPHOME_F("binary_sensor"), value ? "ON" : "OFF", value, start_config);
if (start_config == DETAIL_ALL) {
this->add_sorting_info_(root, obj);
}
@@ -987,7 +988,7 @@ void WebServer::fan_all_json_generator(WebServer *web_server, void *source, json
void WebServer::fan_json_(fan::Fan *obj, JsonDetail start_config, json::JsonBuilder &builder) {
JsonObject root = builder.root();
set_json_icon_state_value(root, obj, "fan", obj->state ? "ON" : "OFF", obj->state, start_config);
set_json_icon_state_value(root, obj, ESPHOME_F("fan"), obj->state ? "ON" : "OFF", obj->state, start_config);
const auto traits = obj->get_traits();
if (traits.supports_speed()) {
root[ESPHOME_F("speed_level")] = obj->speed;
@@ -1062,7 +1063,7 @@ void WebServer::light_all_json_generator(WebServer *web_server, void *source, js
void WebServer::light_json_(light::LightState *obj, JsonDetail start_config, json::JsonBuilder &builder) {
JsonObject root = builder.root();
set_json_value(root, obj, "light", obj->get_reported_values().is_on() ? "ON" : "OFF", start_config);
set_json_value(root, obj, ESPHOME_F("light"), obj->get_reported_values().is_on() ? "ON" : "OFF", start_config);
light::LightJSONSchema::dump_json(*obj, root);
if (start_config == DETAIL_ALL) {
@@ -1131,8 +1132,8 @@ void WebServer::cover_all_json_generator(WebServer *web_server, void *source, js
void WebServer::cover_json_(cover::Cover *obj, JsonDetail start_config, json::JsonBuilder &builder) {
JsonObject root = builder.root();
set_json_icon_state_value(root, obj, "cover", linked(obj->is_fully_closed() ? "CLOSED" : "OPEN"), obj->position,
start_config);
set_json_icon_state_value(root, obj, ESPHOME_F("cover"), linked(obj->is_fully_closed() ? "CLOSED" : "OPEN"),
obj->position, start_config);
root[ESPHOME_F("current_operation")] = json_state_str(cover::cover_operation_to_str(obj->current_operation));
if (obj->get_traits().get_supports_position())
@@ -1202,7 +1203,7 @@ void WebServer::number_json_(number::Number *obj, JsonDetail start_config, json:
val_str = JsonString(val_buf);
state_str = JsonString(state_buf);
}
set_json_icon_state_value(root, obj, "number", state_str, val_str, start_config);
set_json_icon_state_value(root, obj, ESPHOME_F("number"), state_str, val_str, start_config);
if (start_config == DETAIL_ALL) {
// ArduinoJson copies the string immediately, so we can reuse val_buf
root[ESPHOME_F("min_value")] = (value_accuracy_to_buf(val_buf, obj->traits.get_min_value(), accuracy), val_buf);
@@ -1264,7 +1265,7 @@ void WebServer::date_json_(datetime::DateEntity *obj, JsonDetail start_config, j
// Format: YYYY-MM-DD (max 10 chars + null)
char value[12];
buf_append_printf(value, sizeof(value), 0, "%d-%02d-%02d", obj->year, obj->month, obj->day);
set_json_icon_state_value<const char *, const char *>(root, obj, "date", value, value, start_config);
set_json_icon_state_value<const char *, const char *>(root, obj, ESPHOME_F("date"), value, value, start_config);
if (start_config == DETAIL_ALL) {
this->add_sorting_info_(root, obj);
}
@@ -1318,7 +1319,7 @@ void WebServer::time_json_(datetime::TimeEntity *obj, JsonDetail start_config, j
// Format: HH:MM:SS (8 chars + null)
char value[12];
buf_append_printf(value, sizeof(value), 0, "%02d:%02d:%02d", obj->hour, obj->minute, obj->second);
set_json_icon_state_value<const char *, const char *>(root, obj, "time", value, value, start_config);
set_json_icon_state_value<const char *, const char *>(root, obj, ESPHOME_F("time"), value, value, start_config);
if (start_config == DETAIL_ALL) {
this->add_sorting_info_(root, obj);
}
@@ -1375,7 +1376,7 @@ void WebServer::datetime_json_(datetime::DateTimeEntity *obj, JsonDetail start_c
char value[24];
buf_append_printf(value, sizeof(value), 0, "%d-%02d-%02d %02d:%02d:%02d", obj->year, obj->month, obj->day, obj->hour,
obj->minute, obj->second);
set_json_icon_state_value<const char *, const char *>(root, obj, "datetime", value, value, start_config);
set_json_icon_state_value<const char *, const char *>(root, obj, ESPHOME_F("datetime"), value, value, start_config);
if (start_config == DETAIL_ALL) {
this->add_sorting_info_(root, obj);
}
@@ -1429,7 +1430,7 @@ void WebServer::text_json_(text::Text *obj, const std::string &value, JsonDetail
// A password entity shows the mask and prefills the input with nothing, so the secret never
// reaches the JSON and the mask cannot be written back as the value
const bool password = obj->traits.get_mode() == text::TextMode::TEXT_MODE_PASSWORD;
set_json_icon_state_value(root, obj, "text", password ? linked("********") : copied_value,
set_json_icon_state_value(root, obj, ESPHOME_F("text"), password ? linked("********") : copied_value,
password ? linked("") : copied_value, start_config);
root[ESPHOME_F("min_length")] = obj->traits.get_min_length();
root[ESPHOME_F("max_length")] = obj->traits.get_max_length();
@@ -1486,7 +1487,7 @@ void WebServer::select_json_(select::Select *obj, StringRef value, JsonDetail st
JsonObject root = builder.root();
const JsonString state = linked(value);
set_json_icon_state_value(root, obj, "select", state, state, start_config);
set_json_icon_state_value(root, obj, ESPHOME_F("select"), state, state, start_config);
if (start_config == DETAIL_ALL) {
JsonArray opt = root[ESPHOME_F("option")].to<JsonArray>();
for (auto &option : obj->traits.get_options()) {
@@ -1561,7 +1562,7 @@ void WebServer::climate_all_json_generator(WebServer *web_server, void *source,
void WebServer::climate_json_(climate::Climate *obj, JsonDetail start_config, json::JsonBuilder &builder) {
// NOLINTBEGIN(clang-analyzer-cplusplus.NewDeleteLeaks) false positive with ArduinoJson
JsonObject root = builder.root();
set_json_id(root, obj, "climate", start_config);
set_json_id(root, obj, ESPHOME_F("climate"), start_config);
const auto traits = obj->get_traits();
int8_t target_accuracy = traits.get_target_temperature_accuracy_decimals();
int8_t current_accuracy = traits.get_current_temperature_accuracy_decimals();
@@ -1726,7 +1727,8 @@ void WebServer::lock_json_(lock::Lock *obj, lock::LockState value, JsonDetail st
json::JsonBuilder &builder) {
JsonObject root = builder.root();
set_json_icon_state_value(root, obj, "lock", json_state_str(lock::lock_state_to_string(value)), value, start_config);
set_json_icon_state_value(root, obj, ESPHOME_F("lock"), json_state_str(lock::lock_state_to_string(value)), value,
start_config);
if (start_config == DETAIL_ALL) {
this->add_sorting_info_(root, obj);
}
@@ -1786,8 +1788,8 @@ void WebServer::valve_all_json_generator(WebServer *web_server, void *source, js
void WebServer::valve_json_(valve::Valve *obj, JsonDetail start_config, json::JsonBuilder &builder) {
JsonObject root = builder.root();
set_json_icon_state_value(root, obj, "valve", linked(obj->is_fully_closed() ? "CLOSED" : "OPEN"), obj->position,
start_config);
set_json_icon_state_value(root, obj, ESPHOME_F("valve"), linked(obj->is_fully_closed() ? "CLOSED" : "OPEN"),
obj->position, start_config);
root[ESPHOME_F("current_operation")] = json_state_str(valve::valve_operation_to_str(obj->current_operation));
if (obj->get_traits().get_supports_position())
@@ -1858,7 +1860,7 @@ void WebServer::alarm_control_panel_json_(alarm_control_panel::AlarmControlPanel
json::JsonBuilder &builder) {
JsonObject root = builder.root();
set_json_icon_state_value(root, obj, "alarm_control_panel",
set_json_icon_state_value(root, obj, ESPHOME_F("alarm_control_panel"),
json_state_str(alarm_control_panel_state_to_string(value)), value, start_config);
if (start_config == DETAIL_ALL) {
this->add_sorting_info_(root, obj);
@@ -1930,8 +1932,8 @@ void WebServer::water_heater_json_(water_heater::WaterHeater *obj, JsonDetail st
JsonObject root = builder.root();
const auto mode = obj->get_mode();
set_json_icon_state_value(root, obj, "water_heater", json_state_str(water_heater::water_heater_mode_to_string(mode)),
mode, start_config);
set_json_icon_state_value(root, obj, ESPHOME_F("water_heater"),
json_state_str(water_heater::water_heater_mode_to_string(mode)), mode, start_config);
auto traits = obj->get_traits();
@@ -2053,7 +2055,7 @@ void WebServer::infrared_all_json_generator(WebServer *web_server, void *source,
void WebServer::infrared_json_(infrared::Infrared *obj, JsonDetail start_config, json::JsonBuilder &builder) {
JsonObject root = builder.root();
set_json_icon_state_value(root, obj, "infrared", "", 0, start_config);
set_json_icon_state_value(root, obj, ESPHOME_F("infrared"), "", 0, start_config);
root[ESPHOME_F("supports_transmitter")] = obj->get_supports_transmitter();
root[ESPHOME_F("supports_receiver")] = obj->get_supports_receiver();
@@ -2142,7 +2144,7 @@ void WebServer::radio_frequency_json_(radio_frequency::RadioFrequency *obj, Json
json::JsonBuilder &builder) {
JsonObject root = builder.root();
set_json_icon_state_value(root, obj, "radio_frequency", "", 0, start_config);
set_json_icon_state_value(root, obj, ESPHOME_F("radio_frequency"), "", 0, start_config);
const auto &traits = obj->get_traits();
auto caps = obj->get_capability_flags();
@@ -2196,7 +2198,7 @@ void WebServer::event_json_(event::Event *obj, StringRef event_type, JsonDetail
json::JsonBuilder &builder) {
JsonObject root = builder.root();
set_json_id(root, obj, "event", start_config);
set_json_id(root, obj, ESPHOME_F("event"), start_config);
if (!event_type.empty()) {
root[ESPHOME_F("event_type")] = linked(event_type);
}
@@ -2253,7 +2255,7 @@ void WebServer::update_json_(update::UpdateEntity *obj, JsonDetail start_config,
// Not linked: the main loop can rewrite update_info before the document is serialized
const auto &info = obj->update_info;
set_json_icon_state_value(root, obj, "update", json_state_str(update::update_state_to_string(obj->state)),
set_json_icon_state_value(root, obj, ESPHOME_F("update"), json_state_str(update::update_state_to_string(obj->state)),
info.latest_version.c_str(), start_config);
if (start_config == DETAIL_ALL) {
root[ESPHOME_F("current_version")] = info.current_version;