Skip to content

Commit

Permalink
Feature: Add option to clear eventlog at midnight
Browse files Browse the repository at this point in the history
  • Loading branch information
tbnobody committed May 30, 2024
1 parent 3a4f70d commit 6e607f7
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ struct INVERTER_CONFIG_T {
uint8_t ReachableThreshold;
bool ZeroRuntimeDataIfUnrechable;
bool ZeroYieldDayOnMidnight;
bool ClearEventlogOnMidnight;
bool YieldDayCorrection;
CHANNEL_CONFIG_T channel[INV_MAX_CHAN_COUNT];
};
Expand Down
3 changes: 3 additions & 0 deletions lib/Hoymiles/src/Hoymiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ void HoymilesClass::loop()
if (inv->getZeroYieldDayOnMidnight()) {
inv->Statistics()->zeroDailyData();
}
if (inv->getClearEventlogOnMidnight()) {
inv->EventLog()->clearBuffer();
}
}

lastWeekDay = currentWeekDay;
Expand Down
10 changes: 10 additions & 0 deletions lib/Hoymiles/src/inverters/InverterAbstract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@ bool InverterAbstract::getZeroYieldDayOnMidnight() const
return _zeroYieldDayOnMidnight;
}

void InverterAbstract::setClearEventlogOnMidnight(const bool enabled)
{
_clearEventlogOnMidnight = enabled;
}

bool InverterAbstract::getClearEventlogOnMidnight() const
{
return _clearEventlogOnMidnight;
}

bool InverterAbstract::sendChangeChannelRequest()
{
return false;
Expand Down
6 changes: 5 additions & 1 deletion lib/Hoymiles/src/inverters/InverterAbstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class InverterAbstract {
void setZeroYieldDayOnMidnight(const bool enabled);
bool getZeroYieldDayOnMidnight() const;

void setClearEventlogOnMidnight(const bool enabled);
bool getClearEventlogOnMidnight() const;

void clearRxFragmentBuffer();
void addRxFragment(const uint8_t fragment[], const uint8_t len);
uint8_t verifyAllFragments(CommandAbstract& cmd);
Expand Down Expand Up @@ -102,11 +105,12 @@ class InverterAbstract {

bool _zeroValuesIfUnreachable = false;
bool _zeroYieldDayOnMidnight = false;
bool _clearEventlogOnMidnight = false;

std::unique_ptr<AlarmLogParser> _alarmLogParser;
std::unique_ptr<DevInfoParser> _devInfoParser;
std::unique_ptr<GridProfileParser> _gridProfileParser;
std::unique_ptr<PowerCommandParser> _powerCommandParser;
std::unique_ptr<StatisticsParser> _statisticsParser;
std::unique_ptr<SystemConfigParaParser> _systemConfigParaParser;
};
};
2 changes: 2 additions & 0 deletions src/Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ bool ConfigurationClass::write()
inv["reachable_threshold"] = config.Inverter[i].ReachableThreshold;
inv["zero_runtime"] = config.Inverter[i].ZeroRuntimeDataIfUnrechable;
inv["zero_day"] = config.Inverter[i].ZeroYieldDayOnMidnight;
inv["clear_eventlog"] = config.Inverter[i].ClearEventlogOnMidnight;
inv["yieldday_correction"] = config.Inverter[i].YieldDayCorrection;

JsonArray channel = inv["channel"].to<JsonArray>();
Expand Down Expand Up @@ -302,6 +303,7 @@ bool ConfigurationClass::read()
config.Inverter[i].ReachableThreshold = inv["reachable_threshold"] | REACHABLE_THRESHOLD;
config.Inverter[i].ZeroRuntimeDataIfUnrechable = inv["zero_runtime"] | false;
config.Inverter[i].ZeroYieldDayOnMidnight = inv["zero_day"] | false;
config.Inverter[i].ClearEventlogOnMidnight = inv["clear_eventlog"] | false;
config.Inverter[i].YieldDayCorrection = inv["yieldday_correction"] | false;

JsonArray channel = inv["channel"];
Expand Down
1 change: 1 addition & 0 deletions src/InverterSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ void InverterSettingsClass::init(Scheduler& scheduler)
inv->setReachableThreshold(config.Inverter[i].ReachableThreshold);
inv->setZeroValuesIfUnreachable(config.Inverter[i].ZeroRuntimeDataIfUnrechable);
inv->setZeroYieldDayOnMidnight(config.Inverter[i].ZeroYieldDayOnMidnight);
inv->setClearEventlogOnMidnight(config.Inverter[i].ClearEventlogOnMidnight);
inv->Statistics()->setYieldDayCorrection(config.Inverter[i].YieldDayCorrection);
for (uint8_t c = 0; c < INV_MAX_CHAN_COUNT; c++) {
inv->Statistics()->setStringMaxPower(c, config.Inverter[i].channel[c].MaxChannelPower);
Expand Down
3 changes: 3 additions & 0 deletions src/WebApi_inverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ void WebApiInverterClass::onInverterList(AsyncWebServerRequest* request)
obj["reachable_threshold"] = config.Inverter[i].ReachableThreshold;
obj["zero_runtime"] = config.Inverter[i].ZeroRuntimeDataIfUnrechable;
obj["zero_day"] = config.Inverter[i].ZeroYieldDayOnMidnight;
obj["clear_eventlog"] = config.Inverter[i].ClearEventlogOnMidnight;
obj["yieldday_correction"] = config.Inverter[i].YieldDayCorrection;

auto inv = Hoymiles.getInverterBySerial(config.Inverter[i].Serial);
Expand Down Expand Up @@ -225,6 +226,7 @@ void WebApiInverterClass::onInverterEdit(AsyncWebServerRequest* request)
inverter.ReachableThreshold = root["reachable_threshold"] | REACHABLE_THRESHOLD;
inverter.ZeroRuntimeDataIfUnrechable = root["zero_runtime"] | false;
inverter.ZeroYieldDayOnMidnight = root["zero_day"] | false;
inverter.ClearEventlogOnMidnight = root["clear_eventlog"] | false;
inverter.YieldDayCorrection = root["yieldday_correction"] | false;

arrayCount++;
Expand Down Expand Up @@ -254,6 +256,7 @@ void WebApiInverterClass::onInverterEdit(AsyncWebServerRequest* request)
inv->setReachableThreshold(inverter.ReachableThreshold);
inv->setZeroValuesIfUnreachable(inverter.ZeroRuntimeDataIfUnrechable);
inv->setZeroYieldDayOnMidnight(inverter.ZeroYieldDayOnMidnight);
inv->setClearEventlogOnMidnight(inverter.ClearEventlogOnMidnight);
inv->Statistics()->setYieldDayCorrection(inverter.YieldDayCorrection);
for (uint8_t c = 0; c < INV_MAX_CHAN_COUNT; c++) {
inv->Statistics()->setStringMaxPower(c, inverter.channel[c].MaxChannelPower);
Expand Down
1 change: 1 addition & 0 deletions webapp/src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@
"ZeroRuntimeHint": "Nulle Laufzeit Daten (keine Ertragsdaten), wenn der Wechselrichter nicht erreichbar ist.",
"ZeroDay": "Nulle Tagesertrag um Mitternacht",
"ZeroDayHint": "Das funktioniert nur wenn der Wechselrichter nicht erreichbar ist. Wenn Daten aus dem Wechselrichter gelesen werden, werden deren Werte verwendet. (Ein Reset erfolgt nur beim Neustarten)",
"ClearEventlog": "Lösche Ereignisanzeige um Mitternacht",
"Cancel": "@:base.Cancel",
"Save": "@:base.Save",
"DeleteMsg": "Soll der Wechselrichter \"{name}\" mit der Seriennummer {serial} wirklich gelöscht werden?",
Expand Down
1 change: 1 addition & 0 deletions webapp/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@
"ZeroRuntimeHint": "Zero runtime data (no yield data) if inverter becomes unreachable.",
"ZeroDay": "Zero daily yield at midnight",
"ZeroDayHint": "This only works if the inverter is unreachable. If data is read from the inverter, it's values will be used. (Reset only occours on power cycle)",
"ClearEventlog": "Clear Eventlog at midnight",
"Cancel": "@:base.Cancel",
"Save": "@:base.Save",
"DeleteMsg": "Are you sure you want to delete the inverter \"{name}\" with serial number {serial}?",
Expand Down
1 change: 1 addition & 0 deletions webapp/src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@
"ZeroRuntimeHint": "Zero runtime data (no yield data) if inverter becomes unreachable.",
"ZeroDay": "Zero daily yield at midnight",
"ZeroDayHint": "This only works if the inverter is unreachable. If data is read from the inverter, it's values will be used. (Reset only occours on power cycle)",
"ClearEventlog": "Clear Eventlog at midnight",
"Cancel": "@:base.Cancel",
"Save": "@:base.Save",
"DeleteMsg": "Êtes-vous sûr de vouloir supprimer l'onduleur \"{name}\" avec le numéro de série \"{serial}\" ?",
Expand Down
1 change: 1 addition & 0 deletions webapp/src/types/InverterConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface Inverter {
reachable_threshold: number;
zero_runtime: boolean;
zero_day: boolean;
clear_eventlog: boolean;
yieldday_correction: boolean;
channel: Array<InverterChannel>;
}
2 changes: 2 additions & 0 deletions webapp/src/views/InverterAdminView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@
<InputElement :label="$t('inverteradmin.ZeroDay')" v-model="selectedInverterData.zero_day" type="checkbox"
:tooltip="$t('inverteradmin.ZeroDayHint')" wide />

<InputElement :label="$t('inverteradmin.ClearEventlog')" v-model="selectedInverterData.clear_eventlog" type="checkbox" wide />

<InputElement :label="$t('inverteradmin.YieldDayCorrection')"
v-model="selectedInverterData.yieldday_correction" type="checkbox"
:tooltip="$t('inverteradmin.YieldDayCorrectionHint')" wide />
Expand Down

0 comments on commit 6e607f7

Please sign in to comment.