diff --git a/src/WebApi_inverter.cpp b/src/WebApi_inverter.cpp index 79cc2ad..c690fa0 100644 --- a/src/WebApi_inverter.cpp +++ b/src/WebApi_inverter.cpp @@ -173,7 +173,7 @@ void WebApiInverterClass::onInverterEdit(AsyncWebServerRequest* request) return; } - if (!(root.containsKey("id") && root.containsKey("serial") && root.containsKey("name"))) { + if (!(root.containsKey("id") && root.containsKey("serial") && root.containsKey("name") && root.containsKey("max_power"))) { retMsg[F("message")] = F("Values are missing!"); response->setLength(); request->send(response); @@ -201,12 +201,32 @@ void WebApiInverterClass::onInverterEdit(AsyncWebServerRequest* request) return; } + JsonArray maxPowerArray = root[F("max_power")].as(); + uint8_t arrayCount = 0; + for (JsonVariant maxPower : maxPowerArray) { + arrayCount++; + } + if (arrayCount != INV_MAX_CHAN_COUNT) { + retMsg[F("message")] = F("Invalid amount of max channel setting given!"); + response->setLength(); + request->send(response); + return; + } + + INVERTER_CONFIG_T& inverter = Configuration.get().Inverter[root[F("id")].as()]; char* t; // Interpret the string as a hex value and convert it to uint64_t inverter.Serial = strtoll(root[F("serial")].as().c_str(), &t, 16); strncpy(inverter.Name, root[F("name")].as().c_str(), INV_MAX_NAME_STRLEN); + + arrayCount = 0; + for (JsonVariant maxPower : maxPowerArray) { + inverter.MaxChannelPower[arrayCount] = maxPower.as(); + arrayCount++; + } + Configuration.write(); retMsg[F("type")] = F("success"); diff --git a/webapp/src/components/InverterAdminView.vue b/webapp/src/components/InverterAdminView.vue index e0285ba..14c3ec9 100644 --- a/webapp/src/components/InverterAdminView.vue +++ b/webapp/src/components/InverterAdminView.vue @@ -44,56 +44,82 @@ - - + + + {{ inverter.serial }} + + + {{ inverter.name }} + + + {{ inverter.type }} + + + + + + + + + + + +