mirror of
https://github.com/lumapu/ahoy.git
synced 2025-04-29 18:26:21 +02:00
0.8.129
* sort alarms ascending #1471 * fix alarm counter for first alarm * prevent add inverter multiple times #1700
This commit is contained in:
parent
dcb4b49fa0
commit
3c0c8eece3
4 changed files with 37 additions and 8 deletions
|
@ -1,8 +1,13 @@
|
|||
# Development Changes
|
||||
|
||||
## 0.8.129 - 2024-07-11
|
||||
* sort alarms ascending #1471
|
||||
* fix alarm counter for first alarm
|
||||
* prevent add inverter multiple times #1700
|
||||
|
||||
## 0.8.128 - 2024-07-10
|
||||
* add environments for 16MB flash size ESP32-S3 aka opendtufusion
|
||||
* prevent duplicate alarms, update end time once it is received
|
||||
* prevent duplicate alarms, update end time once it is received #1471
|
||||
|
||||
## 0.8.127 - 2024-06-21
|
||||
* add grid file #1677
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
//-------------------------------------
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 8
|
||||
#define VERSION_PATCH 128
|
||||
#define VERSION_PATCH 129
|
||||
//-------------------------------------
|
||||
typedef struct {
|
||||
uint8_t ch;
|
||||
|
|
|
@ -834,7 +834,7 @@ class Inverter {
|
|||
}
|
||||
}
|
||||
|
||||
if(alarmCnt < 10 && alarmCnt < mAlarmNxtWrPos)
|
||||
if(alarmCnt < 10 && alarmCnt <= mAlarmNxtWrPos)
|
||||
alarmCnt = mAlarmNxtWrPos + 1;
|
||||
|
||||
lastAlarm[mAlarmNxtWrPos] = alarm_t(code, start, end);
|
||||
|
|
|
@ -704,11 +704,23 @@ class RestApi {
|
|||
obj[F("last_id")] = iv->getChannelFieldValue(CH0, FLD_EVT, rec);
|
||||
|
||||
JsonArray alarm = obj.createNestedArray(F("alarm"));
|
||||
|
||||
// find oldest alarm
|
||||
uint8_t offset = 0;
|
||||
uint32_t oldestStart = 0xffffffff;
|
||||
for(uint8_t i = 0; i < 10; i++) {
|
||||
alarm[i][F("code")] = iv->lastAlarm[i].code;
|
||||
alarm[i][F("str")] = iv->getAlarmStr(iv->lastAlarm[i].code);
|
||||
alarm[i][F("start")] = iv->lastAlarm[i].start;
|
||||
alarm[i][F("end")] = iv->lastAlarm[i].end;
|
||||
if((iv->lastAlarm[i].start != 0) && (iv->lastAlarm[i].start < oldestStart)) {
|
||||
offset = i;
|
||||
oldestStart = iv->lastAlarm[i].start;
|
||||
}
|
||||
}
|
||||
|
||||
for(uint8_t i = 0; i < 10; i++) {
|
||||
uint8_t pos = (i + offset) % 10;
|
||||
alarm[pos][F("code")] = iv->lastAlarm[pos].code;
|
||||
alarm[pos][F("str")] = iv->getAlarmStr(iv->lastAlarm[pos].code);
|
||||
alarm[pos][F("start")] = iv->lastAlarm[pos].start;
|
||||
alarm[pos][F("end")] = iv->lastAlarm[pos].end;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1105,7 +1117,19 @@ class RestApi {
|
|||
}
|
||||
#endif /* !defined(ETHERNET */
|
||||
else if(F("save_iv") == jsonIn[F("cmd")]) {
|
||||
Inverter<> *iv = mSys->getInverterByPos(jsonIn[F("id")], false);
|
||||
Inverter<> *iv;
|
||||
|
||||
for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) {
|
||||
iv = mSys->getInverterByPos(jsonIn[F("id")], true);
|
||||
if(nullptr != iv) {
|
||||
if((i != jsonIn[F("id")]) && (iv->config->serial.u64 == jsonIn[F("ser")])) {
|
||||
jsonOut[F("error")] = F("ERR_DUPLICATE_INVERTER");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
iv = mSys->getInverterByPos(jsonIn[F("id")], false);
|
||||
iv->config->enabled = jsonIn[F("en")];
|
||||
iv->config->serial.u64 = jsonIn[F("ser")];
|
||||
snprintf(iv->config->name, MAX_NAME_LENGTH, "%s", jsonIn[F("name")].as<const char*>());
|
||||
|
|
Loading…
Add table
Reference in a new issue