Fix: Set all settings to default when deleting an inverters
Previously some old settings from previous inverters could have been shown in a new inverter
This commit is contained in:
parent
437f572c39
commit
33bf2117c6
@ -168,6 +168,7 @@ public:
|
|||||||
|
|
||||||
INVERTER_CONFIG_T* getFreeInverterSlot();
|
INVERTER_CONFIG_T* getFreeInverterSlot();
|
||||||
INVERTER_CONFIG_T* getInverterConfig(const uint64_t serial);
|
INVERTER_CONFIG_T* getInverterConfig(const uint64_t serial);
|
||||||
|
void deleteInverterById(const uint8_t id);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern ConfigurationClass Configuration;
|
extern ConfigurationClass Configuration;
|
||||||
|
|||||||
@ -406,4 +406,26 @@ INVERTER_CONFIG_T* ConfigurationClass::getInverterConfig(const uint64_t serial)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConfigurationClass::deleteInverterById(const uint8_t id)
|
||||||
|
{
|
||||||
|
config.Inverter[id].Serial = 0ULL;
|
||||||
|
strlcpy(config.Inverter[id].Name, "", sizeof(config.Inverter[id].Name));
|
||||||
|
config.Inverter[id].Order = 0;
|
||||||
|
|
||||||
|
config.Inverter[id].Poll_Enable = true;
|
||||||
|
config.Inverter[id].Poll_Enable_Night = true;
|
||||||
|
config.Inverter[id].Command_Enable = true;
|
||||||
|
config.Inverter[id].Command_Enable_Night = true;
|
||||||
|
config.Inverter[id].ReachableThreshold = REACHABLE_THRESHOLD;
|
||||||
|
config.Inverter[id].ZeroRuntimeDataIfUnrechable = false;
|
||||||
|
config.Inverter[id].ZeroYieldDayOnMidnight = false;
|
||||||
|
config.Inverter[id].YieldDayCorrection = false;
|
||||||
|
|
||||||
|
for (uint8_t c = 0; c < INV_MAX_CHAN_COUNT; c++) {
|
||||||
|
config.Inverter[id].channel[c].MaxChannelPower = 0;
|
||||||
|
config.Inverter[id].channel[c].YieldTotalOffset = 0.0f;
|
||||||
|
strlcpy(config.Inverter[id].channel[c].Name, "", sizeof(config.Inverter[id].channel[c].Name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ConfigurationClass Configuration;
|
ConfigurationClass Configuration;
|
||||||
|
|||||||
@ -386,8 +386,7 @@ void WebApiInverterClass::onInverterDelete(AsyncWebServerRequest* request)
|
|||||||
|
|
||||||
Hoymiles.removeInverterBySerial(inverter.Serial);
|
Hoymiles.removeInverterBySerial(inverter.Serial);
|
||||||
|
|
||||||
inverter.Serial = 0;
|
Configuration.deleteInverterById(inverter_id);
|
||||||
strncpy(inverter.Name, "", sizeof(inverter.Name));
|
|
||||||
|
|
||||||
WebApi.writeConfig(retMsg, WebApiError::InverterDeleted, "Inverter deleted!");
|
WebApi.writeConfig(retMsg, WebApiError::InverterDeleted, "Inverter deleted!");
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user