Add configurable Sofar ID via Webserver

This commit is contained in:
Daniel Öster 2025-07-03 20:06:35 +03:00
parent 25c60cb42b
commit 920cd83561
6 changed files with 39 additions and 3 deletions

View file

@ -487,6 +487,20 @@ void init_webserver() {
}
});
// Route for editing Sofar ID
server.on("/updateSofarID", HTTP_GET, [](AsyncWebServerRequest* request) {
if (WEBSERVER_AUTH_REQUIRED && !request->authenticate(http_username, http_password))
return request->requestAuthentication();
if (request->hasParam("value")) {
String value = request->getParam("value")->value();
datalayer.battery.settings.sofar_user_specified_battery_id = value.toInt();
store_settings();
request->send(200, "text/plain", "Updated successfully");
} else {
request->send(400, "text/plain", "Bad Request");
}
});
// Route for editing Wh
server.on("/updateBatterySize", HTTP_GET, [](AsyncWebServerRequest* request) {
if (WEBSERVER_AUTH_REQUIRED && !request->authenticate(http_username, http_password))