mirror of
https://github.com/esphome/esphome.git
synced 2026-03-03 11:18:21 -07:00
[select] Refactor to index-based operations for immediate and future RAM savings (#11623)
This commit is contained in:
@@ -1188,7 +1188,7 @@ void WebServer::handle_select_request(AsyncWebServerRequest *request, const UrlM
|
||||
|
||||
if (request->method() == HTTP_GET && match.method_empty()) {
|
||||
auto detail = get_request_detail(request);
|
||||
std::string data = this->select_json(obj, obj->state, detail);
|
||||
std::string data = this->select_json(obj, obj->has_state() ? obj->current_option() : "", detail);
|
||||
request->send(200, "application/json", data.c_str());
|
||||
return;
|
||||
}
|
||||
@@ -1208,12 +1208,14 @@ void WebServer::handle_select_request(AsyncWebServerRequest *request, const UrlM
|
||||
request->send(404);
|
||||
}
|
||||
std::string WebServer::select_state_json_generator(WebServer *web_server, void *source) {
|
||||
return web_server->select_json((select::Select *) (source), ((select::Select *) (source))->state, DETAIL_STATE);
|
||||
auto *obj = (select::Select *) (source);
|
||||
return web_server->select_json(obj, obj->has_state() ? obj->current_option() : "", DETAIL_STATE);
|
||||
}
|
||||
std::string WebServer::select_all_json_generator(WebServer *web_server, void *source) {
|
||||
return web_server->select_json((select::Select *) (source), ((select::Select *) (source))->state, DETAIL_ALL);
|
||||
auto *obj = (select::Select *) (source);
|
||||
return web_server->select_json(obj, obj->has_state() ? obj->current_option() : "", DETAIL_ALL);
|
||||
}
|
||||
std::string WebServer::select_json(select::Select *obj, const std::string &value, JsonDetail start_config) {
|
||||
std::string WebServer::select_json(select::Select *obj, const char *value, JsonDetail start_config) {
|
||||
json::JsonBuilder builder;
|
||||
JsonObject root = builder.root();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user