mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 07:03:55 +00:00 
			
		
		
		
	Merge branch 'webserver_helper_reduce_flash' into integration
This commit is contained in:
		| @@ -373,7 +373,7 @@ void WebServer::handle_js_request(AsyncWebServerRequest *request) { | ||||
|   (root)["state"] = state; | ||||
|  | ||||
| // Helper to get request detail parameter | ||||
| static JsonDetail get_request_detail_(AsyncWebServerRequest *request) { | ||||
| static JsonDetail get_request_detail(AsyncWebServerRequest *request) { | ||||
|   auto *param = request->getParam("detail"); | ||||
|   return (param && param->value() == "all") ? DETAIL_ALL : DETAIL_STATE; | ||||
| } | ||||
| @@ -389,7 +389,7 @@ void WebServer::handle_sensor_request(AsyncWebServerRequest *request, const UrlM | ||||
|     if (obj->get_object_id() != match.id) | ||||
|       continue; | ||||
|     if (request->method() == HTTP_GET && match.method.empty()) { | ||||
|       auto detail = get_request_detail_(request); | ||||
|       auto detail = get_request_detail(request); | ||||
|       std::string data = this->sensor_json(obj, obj->state, detail); | ||||
|       request->send(200, "application/json", data.c_str()); | ||||
|       return; | ||||
| @@ -434,7 +434,7 @@ void WebServer::handle_text_sensor_request(AsyncWebServerRequest *request, const | ||||
|     if (obj->get_object_id() != match.id) | ||||
|       continue; | ||||
|     if (request->method() == HTTP_GET && match.method.empty()) { | ||||
|       auto detail = get_request_detail_(request); | ||||
|       auto detail = get_request_detail(request); | ||||
|       std::string data = this->text_sensor_json(obj, obj->state, detail); | ||||
|       request->send(200, "application/json", data.c_str()); | ||||
|       return; | ||||
| @@ -473,7 +473,7 @@ void WebServer::handle_switch_request(AsyncWebServerRequest *request, const UrlM | ||||
|       continue; | ||||
|  | ||||
|     if (request->method() == HTTP_GET && match.method.empty()) { | ||||
|       auto detail = get_request_detail_(request); | ||||
|       auto detail = get_request_detail(request); | ||||
|       std::string data = this->switch_json(obj, obj->state, detail); | ||||
|       request->send(200, "application/json", data.c_str()); | ||||
|     } else if (match.method == "toggle") { | ||||
| @@ -515,7 +515,7 @@ void WebServer::handle_button_request(AsyncWebServerRequest *request, const UrlM | ||||
|     if (obj->get_object_id() != match.id) | ||||
|       continue; | ||||
|     if (request->method() == HTTP_GET && match.method.empty()) { | ||||
|       auto detail = get_request_detail_(request); | ||||
|       auto detail = get_request_detail(request); | ||||
|       std::string data = this->button_json(obj, detail); | ||||
|       request->send(200, "application/json", data.c_str()); | ||||
|     } else if (match.method == "press") { | ||||
| @@ -556,7 +556,7 @@ void WebServer::handle_binary_sensor_request(AsyncWebServerRequest *request, con | ||||
|     if (obj->get_object_id() != match.id) | ||||
|       continue; | ||||
|     if (request->method() == HTTP_GET && match.method.empty()) { | ||||
|       auto detail = get_request_detail_(request); | ||||
|       auto detail = get_request_detail(request); | ||||
|       std::string data = this->binary_sensor_json(obj, obj->state, detail); | ||||
|       request->send(200, "application/json", data.c_str()); | ||||
|       return; | ||||
| @@ -595,7 +595,7 @@ void WebServer::handle_fan_request(AsyncWebServerRequest *request, const UrlMatc | ||||
|       continue; | ||||
|  | ||||
|     if (request->method() == HTTP_GET && match.method.empty()) { | ||||
|       auto detail = get_request_detail_(request); | ||||
|       auto detail = get_request_detail(request); | ||||
|       std::string data = this->fan_json(obj, detail); | ||||
|       request->send(200, "application/json", data.c_str()); | ||||
|     } else if (match.method == "toggle") { | ||||
| @@ -676,7 +676,7 @@ void WebServer::handle_light_request(AsyncWebServerRequest *request, const UrlMa | ||||
|       continue; | ||||
|  | ||||
|     if (request->method() == HTTP_GET && match.method.empty()) { | ||||
|       auto detail = get_request_detail_(request); | ||||
|       auto detail = get_request_detail(request); | ||||
|       std::string data = this->light_json(obj, detail); | ||||
|       request->send(200, "application/json", data.c_str()); | ||||
|     } else if (match.method == "toggle") { | ||||
| @@ -792,7 +792,7 @@ void WebServer::handle_cover_request(AsyncWebServerRequest *request, const UrlMa | ||||
|       continue; | ||||
|  | ||||
|     if (request->method() == HTTP_GET && match.method.empty()) { | ||||
|       auto detail = get_request_detail_(request); | ||||
|       auto detail = get_request_detail(request); | ||||
|       std::string data = this->cover_json(obj, detail); | ||||
|       request->send(200, "application/json", data.c_str()); | ||||
|       return; | ||||
| @@ -873,7 +873,7 @@ void WebServer::handle_number_request(AsyncWebServerRequest *request, const UrlM | ||||
|       continue; | ||||
|  | ||||
|     if (request->method() == HTTP_GET && match.method.empty()) { | ||||
|       auto detail = get_request_detail_(request); | ||||
|       auto detail = get_request_detail(request); | ||||
|       std::string data = this->number_json(obj, obj->state, detail); | ||||
|       request->send(200, "application/json", data.c_str()); | ||||
|       return; | ||||
| @@ -943,7 +943,7 @@ void WebServer::handle_date_request(AsyncWebServerRequest *request, const UrlMat | ||||
|     if (obj->get_object_id() != match.id) | ||||
|       continue; | ||||
|     if (request->method() == HTTP_GET && match.method.empty()) { | ||||
|       auto detail = get_request_detail_(request); | ||||
|       auto detail = get_request_detail(request); | ||||
|       std::string data = this->date_json(obj, detail); | ||||
|       request->send(200, "application/json", data.c_str()); | ||||
|       return; | ||||
| @@ -1002,7 +1002,7 @@ void WebServer::handle_time_request(AsyncWebServerRequest *request, const UrlMat | ||||
|     if (obj->get_object_id() != match.id) | ||||
|       continue; | ||||
|     if (request->method() == HTTP_GET && match.method.empty()) { | ||||
|       auto detail = get_request_detail_(request); | ||||
|       auto detail = get_request_detail(request); | ||||
|       std::string data = this->time_json(obj, detail); | ||||
|       request->send(200, "application/json", data.c_str()); | ||||
|       return; | ||||
| @@ -1060,7 +1060,7 @@ void WebServer::handle_datetime_request(AsyncWebServerRequest *request, const Ur | ||||
|     if (obj->get_object_id() != match.id) | ||||
|       continue; | ||||
|     if (request->method() == HTTP_GET && match.method.empty()) { | ||||
|       auto detail = get_request_detail_(request); | ||||
|       auto detail = get_request_detail(request); | ||||
|       std::string data = this->datetime_json(obj, detail); | ||||
|       request->send(200, "application/json", data.c_str()); | ||||
|       return; | ||||
| @@ -1120,7 +1120,7 @@ void WebServer::handle_text_request(AsyncWebServerRequest *request, const UrlMat | ||||
|       continue; | ||||
|  | ||||
|     if (request->method() == HTTP_GET && match.method.empty()) { | ||||
|       auto detail = get_request_detail_(request); | ||||
|       auto detail = get_request_detail(request); | ||||
|       std::string data = this->text_json(obj, obj->state, detail); | ||||
|       request->send(200, "application/json", data.c_str()); | ||||
|       return; | ||||
| @@ -1181,7 +1181,7 @@ void WebServer::handle_select_request(AsyncWebServerRequest *request, const UrlM | ||||
|       continue; | ||||
|  | ||||
|     if (request->method() == HTTP_GET && match.method.empty()) { | ||||
|       auto detail = get_request_detail_(request); | ||||
|       auto detail = get_request_detail(request); | ||||
|       std::string data = this->select_json(obj, obj->state, detail); | ||||
|       request->send(200, "application/json", data.c_str()); | ||||
|       return; | ||||
| @@ -1240,7 +1240,7 @@ void WebServer::handle_climate_request(AsyncWebServerRequest *request, const Url | ||||
|       continue; | ||||
|  | ||||
|     if (request->method() == HTTP_GET && match.method.empty()) { | ||||
|       auto detail = get_request_detail_(request); | ||||
|       auto detail = get_request_detail(request); | ||||
|       std::string data = this->climate_json(obj, detail); | ||||
|       request->send(200, "application/json", data.c_str()); | ||||
|       return; | ||||
| @@ -1399,7 +1399,7 @@ void WebServer::handle_lock_request(AsyncWebServerRequest *request, const UrlMat | ||||
|       continue; | ||||
|  | ||||
|     if (request->method() == HTTP_GET && match.method.empty()) { | ||||
|       auto detail = get_request_detail_(request); | ||||
|       auto detail = get_request_detail(request); | ||||
|       std::string data = this->lock_json(obj, obj->state, detail); | ||||
|       request->send(200, "application/json", data.c_str()); | ||||
|     } else if (match.method == "lock") { | ||||
| @@ -1447,7 +1447,7 @@ void WebServer::handle_valve_request(AsyncWebServerRequest *request, const UrlMa | ||||
|       continue; | ||||
|  | ||||
|     if (request->method() == HTTP_GET && match.method.empty()) { | ||||
|       auto detail = get_request_detail_(request); | ||||
|       auto detail = get_request_detail(request); | ||||
|       std::string data = this->valve_json(obj, detail); | ||||
|       request->send(200, "application/json", data.c_str()); | ||||
|       return; | ||||
| @@ -1519,7 +1519,7 @@ void WebServer::handle_alarm_control_panel_request(AsyncWebServerRequest *reques | ||||
|       continue; | ||||
|  | ||||
|     if (request->method() == HTTP_GET && match.method.empty()) { | ||||
|       auto detail = get_request_detail_(request); | ||||
|       auto detail = get_request_detail(request); | ||||
|       std::string data = this->alarm_control_panel_json(obj, obj->get_state(), detail); | ||||
|       request->send(200, "application/json", data.c_str()); | ||||
|       return; | ||||
| @@ -1586,7 +1586,7 @@ void WebServer::handle_event_request(AsyncWebServerRequest *request, const UrlMa | ||||
|       continue; | ||||
|  | ||||
|     if (request->method() == HTTP_GET && match.method.empty()) { | ||||
|       auto detail = get_request_detail_(request); | ||||
|       auto detail = get_request_detail(request); | ||||
|       std::string data = this->event_json(obj, "", detail); | ||||
|       request->send(200, "application/json", data.c_str()); | ||||
|       return; | ||||
| @@ -1632,7 +1632,7 @@ void WebServer::handle_update_request(AsyncWebServerRequest *request, const UrlM | ||||
|       continue; | ||||
|  | ||||
|     if (request->method() == HTTP_GET && match.method.empty()) { | ||||
|       auto detail = get_request_detail_(request); | ||||
|       auto detail = get_request_detail(request); | ||||
|       std::string data = this->update_json(obj, detail); | ||||
|       request->send(200, "application/json", data.c_str()); | ||||
|       return; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user