Show the correct amount of string input fields in inverter config
This commit is contained in:
parent
11c272b1fb
commit
ab0029d9fd
@ -53,13 +53,16 @@ void WebApiInverterClass::onInverterList(AsyncWebServerRequest* request)
|
|||||||
obj[F("serial")] = buffer;
|
obj[F("serial")] = buffer;
|
||||||
|
|
||||||
auto inv = Hoymiles.getInverterBySerial(config.Inverter[i].Serial);
|
auto inv = Hoymiles.getInverterBySerial(config.Inverter[i].Serial);
|
||||||
|
uint8_t max_channels;
|
||||||
if (inv == nullptr) {
|
if (inv == nullptr) {
|
||||||
obj[F("type")] = F("Unknown");
|
obj[F("type")] = F("Unknown");
|
||||||
|
max_channels = INV_MAX_CHAN_COUNT;
|
||||||
} else {
|
} else {
|
||||||
obj[F("type")] = inv->typeName();
|
obj[F("type")] = inv->typeName();
|
||||||
|
max_channels = inv->Statistics()->getChannelCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint8_t c = 0; c < INV_MAX_CHAN_COUNT; c++) {
|
for (uint8_t c = 0; c < max_channels; c++) {
|
||||||
obj[F("max_power")][c] = config.Inverter[i].MaxChannelPower[c];
|
obj[F("max_power")][c] = config.Inverter[i].MaxChannelPower[c];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -223,7 +226,7 @@ void WebApiInverterClass::onInverterEdit(AsyncWebServerRequest* request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
JsonArray maxPowerArray = root[F("max_power")].as<JsonArray>();
|
JsonArray maxPowerArray = root[F("max_power")].as<JsonArray>();
|
||||||
if (maxPowerArray.size() != INV_MAX_CHAN_COUNT) {
|
if (maxPowerArray.size() == 0 || maxPowerArray.size() > INV_MAX_CHAN_COUNT) {
|
||||||
retMsg[F("message")] = F("Invalid amount of max channel setting given!");
|
retMsg[F("message")] = F("Invalid amount of max channel setting given!");
|
||||||
response->setLength();
|
response->setLength();
|
||||||
request->send(response);
|
request->send(response);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user