Browse Source

0.8.119

* add yield day to history graph #1614
main
lumapu 8 months ago
parent
commit
e0924303f7
  1. 3
      src/CHANGES.md
  2. 1
      src/platformio.ini
  3. 2
      src/plugins/history.h
  4. 45
      src/web/RestApi.h
  5. 7
      src/web/html/history.html
  6. 5
      src/web/lang.json

3
src/CHANGES.md

@ -1,8 +1,9 @@
# Development Changes
## 0.8.119 - 2024-05-16
## 0.8.119 - 2024-05-17
* fix reset values at midnight if WiFi isn't available #1620
* fix typo in English versions
* add yield day to history graph #1614
## 0.8.118 - 2024-05-10
* possible fix reset max values #1609

1
src/platformio.ini

@ -163,6 +163,7 @@ build_flags = ${env:esp32-wroom32-minimal.build_flags}
-DENABLE_MQTT
-DPLUGIN_DISPLAY
-DENABLE_HISTORY
-DENABLE_SIMULATOR
monitor_filters =
esp32_exception_decoder

2
src/plugins/history.h

@ -62,9 +62,9 @@ class HistoryData {
for (uint8_t i = 0; i < mSys->getNumInverters(); i++) {
Inverter<> *iv = mSys->getInverterByPos(i);
record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug);
if (iv == NULL)
continue;
record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug);
curPwr += iv->getChannelFieldValue(CH0, FLD_PAC, rec);
yldDay += iv->getChannelFieldValue(CH0, FLD_YD, rec);
if (rec->ts > ts)

45
src/web/RestApi.h

@ -103,8 +103,8 @@ class RestApi {
else if(path == "setup/getip") getIp(root);
#endif /* !defined(ETHERNET) */
else if(path == "live") getLive(request,root);
else if (path == "powerHistory") getPowerHistory(request, root);
else if (path == "powerHistoryDay") getPowerHistoryDay(request, root);
else if (path == "powerHistory") getPowerHistory(request, root, HistoryStorageType::POWER);
else if (path == "powerHistoryDay") getPowerHistory(request, root, HistoryStorageType::POWER_DAY);
else {
if(path.substring(0, 12) == "inverter/id/")
getInverter(root, request->url().substring(17).toInt());
@ -927,40 +927,37 @@ class RestApi {
}
}
void getPowerHistory(AsyncWebServerRequest *request, JsonObject obj) {
void getPowerHistory(AsyncWebServerRequest *request, JsonObject obj, HistoryStorageType type) {
getGeneric(request, obj.createNestedObject(F("generic")));
#if defined(ENABLE_HISTORY)
obj[F("refresh")] = mApp->getHistoryPeriod((uint8_t)HistoryStorageType::POWER);
obj[F("refresh")] = mApp->getHistoryPeriod(static_cast<uint8_t>(type));
uint16_t max = 0;
for (uint16_t fld = 0; fld < HISTORY_DATA_ARR_LENGTH; fld++) {
uint16_t value = mApp->getHistoryValue((uint8_t)HistoryStorageType::POWER, fld);
uint16_t value = mApp->getHistoryValue(static_cast<uint8_t>(type), fld);
obj[F("value")][fld] = value;
if (value > max)
max = value;
}
obj[F("max")] = max;
obj[F("lastValueTs")] = mApp->getHistoryLastValueTs((uint8_t)HistoryStorageType::POWER);
#endif /*ENABLE_HISTORY*/
}
void getPowerHistoryDay(AsyncWebServerRequest *request, JsonObject obj){
//getGeneric(request, obj.createNestedObject(F("generic")));
#if defined(ENABLE_HISTORY)
obj[F("refresh")] = mApp->getHistoryPeriod((uint8_t)HistoryStorageType::POWER_DAY);
uint16_t max = 0;
for (uint16_t fld = 0; fld < HISTORY_DATA_ARR_LENGTH; fld++) {
uint16_t value = mApp->getHistoryValue((uint8_t)HistoryStorageType::POWER_DAY, fld);
obj[F("value")][fld] = value;
if (value > max)
max = value;
if(HistoryStorageType::POWER_DAY == type) {
float yldDay = 0;
for (uint8_t i = 0; i < mSys->getNumInverters(); i++) {
Inverter<> *iv = mSys->getInverterByPos(i);
if (iv == NULL)
continue;
record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug);
yldDay += iv->getChannelFieldValue(CH0, FLD_YD, rec);
}
obj[F("max")] = max;
obj[F("lastValueTs")] = mApp->getHistoryLastValueTs((uint8_t)HistoryStorageType::POWER_DAY);
#endif /*ENABLE_HISTORY*/
obj[F("yld")] = ah::round3(yldDay / 1000.0);
}
obj[F("lastValueTs")] = mApp->getHistoryLastValueTs(static_cast<uint8_t>(type));
#endif /*ENABLE_HISTORY*/
}
void getYieldDayHistory(AsyncWebServerRequest *request, JsonObject obj) {
/*void getYieldDayHistory(AsyncWebServerRequest *request, JsonObject obj) {
//getGeneric(request, obj.createNestedObject(F("generic")));
#if defined(ENABLE_HISTORY) && defined(ENABLE_HISTORY_YIELD_PER_DAY)
obj[F("refresh")] = mApp->getHistoryPeriod((uint8_t)HistoryStorageType::YIELD);
@ -972,8 +969,8 @@ class RestApi {
max = value;
}
obj[F("max")] = max;
#endif /*ENABLE_HISTORY*/
}
#endif
}*/
bool setCtrl(JsonObject jsonIn, JsonObject jsonOut, const char *clientIP) {
if(jsonIn.containsKey(F("auth"))) {

7
src/web/html/history.html

@ -133,12 +133,17 @@
}
let pts2 = pts + " " + String(last) + "," + String(height)
pts2 += " " + String(first) + "," + String(height)
return [
elm = [
mlNs("polyline", {stroke: "url(#gLine)", fill: "none", points: pts}),
mlNs("polyline", {stroke: "none", fill: "url(#gFill)", points: pts2}),
mlNs("text", {x: i*.8, y: 10}, "{#MAXIMUM}: " + String(obj.max) + "W"),
mlNs("text", {x: i*.8, y: 25}, "{#LAST_VALUE}: " + String(lastVal) + "W")
]
if(undefined !== obj.yld)
elm.push(mlNs("text", {x: i*.8, y: 40}, "{#YIELD_DAY}: " + String(obj.yld) + "kWh"))
return elm;
}

5
src/web/lang.json

@ -1587,6 +1587,11 @@
"token": "LAST_VALUE",
"en": "Last value",
"de": "Letzter Wert"
},
{
"token": "YIELD_DAY",
"en": "Yield day",
"de": "Tagesertrag"
}
]
}

Loading…
Cancel
Save