mirror of
https://github.com/esphome/esphome.git
synced 2026-09-14 08:38:39 +00:00
[select] Return std::string_view from current_option()
This commit is contained in:
@@ -709,6 +709,7 @@ void PrometheusHandler::select_row_(AsyncResponseStream *stream, select::Select
|
||||
stream->print(ESPHOME_F("\",name=\""));
|
||||
stream->print(relabel_name_(obj).c_str());
|
||||
stream->print(ESPHOME_F("\",value=\""));
|
||||
// current_option() returns string_view pointing to null-terminated string literals from codegen
|
||||
stream->print(obj->current_option().data());
|
||||
stream->print(ESPHOME_F("\"} "));
|
||||
stream->print(ESPHOME_F("1.0"));
|
||||
|
||||
@@ -1420,6 +1420,7 @@ std::string WebServer::select_json_(select::Select *obj, std::string_view value,
|
||||
json::JsonBuilder builder;
|
||||
JsonObject root = builder.root();
|
||||
|
||||
// value points to null-terminated string literals from codegen (via current_option())
|
||||
set_json_icon_state_value(root, obj, "select", value.data(), value.data(), start_config);
|
||||
if (start_config == DETAIL_ALL) {
|
||||
JsonArray opt = root[ESPHOME_F("option")].to<JsonArray>();
|
||||
|
||||
Reference in New Issue
Block a user