Skip to content

Commit

Permalink
0.8.2
Browse files Browse the repository at this point in the history
* beautified inverter settings in `setup` (preperation for future, settings become more inverter dependent)
  • Loading branch information
lumapu committed Nov 8, 2023
1 parent e550111 commit 975f692
Show file tree
Hide file tree
Showing 12 changed files with 223 additions and 166 deletions.
3 changes: 3 additions & 0 deletions src/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Development Changes

## 0.8.2 - 2023-11-08
* beautified inverter settings in `setup` (preperation for future, settings become more inverter dependent)

## 0.8.1 - 2023-11-05
* added tx channel heuristics (per inverter)
* fix statistics counter
Expand Down
2 changes: 1 addition & 1 deletion src/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
#define MAX_RF_PAYLOAD_SIZE 32

// maximum total payload buffers (must be greater than the number of received frame fragments)
#define MAX_PAYLOAD_ENTRIES 10
#define MAX_PAYLOAD_ENTRIES 20

// number of seconds since last successful response, before inverter is marked inactive
#define INVERTER_INACT_THRES_SEC 5*60
Expand Down
2 changes: 1 addition & 1 deletion src/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//-------------------------------------
#define VERSION_MAJOR 0
#define VERSION_MINOR 8
#define VERSION_PATCH 1
#define VERSION_PATCH 2

//-------------------------------------
typedef struct {
Expand Down
3 changes: 0 additions & 3 deletions src/hm/hmInverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ class Inverter {
record_t<REC_TYP> recordHwInfo; // structure for simple (hardware) info values
record_t<REC_TYP> recordConfig; // structure for system config values
record_t<REC_TYP> recordAlarm; // structure for alarm values
bool initialized; // needed to check if the inverter was correctly added (ESP32 specific - union types are never null)
bool isConnected; // shows if inverter was successfully identified (fw version and hardware info)
InverterStatus status; // indicates the current inverter status
std::array<alarm_t, 10> lastAlarm; // holds last 10 alarms
Expand All @@ -142,7 +141,6 @@ class Inverter {
actPowerLimit = 0xffff; // init feedback from inverter to -1
mDevControlRequest = false;
devControlCmd = InitDataState;
initialized = false;
alarmMesIndex = 0;
isConnected = false;
status = InverterStatus::OFF;
Expand Down Expand Up @@ -193,7 +191,6 @@ class Inverter {
initAssignment(&recordConfig, SystemConfigPara);
initAssignment(&recordAlarm, AlarmData);
toRadioId();
initialized = true;
}

uint8_t getPosByChFld(uint8_t channel, uint8_t fieldId, record_t<> *rec) {
Expand Down
2 changes: 1 addition & 1 deletion src/hm/hmSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class HmSystem {
DPRINTLN(DBG_VERBOSE, F("hmSystem.h:getInverterByPos"));
if(pos >= MAX_INVERTER)
return NULL;
else if((mInverter[pos].initialized && mInverter[pos].config->serial.u64 != 0ULL) || false == check)
else if((mInverter[pos].config->serial.u64 != 0ULL) || (false == check))
return &mInverter[pos];
else
return NULL;
Expand Down
31 changes: 29 additions & 2 deletions src/web/RestApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class RestApi {

void onApiPostBody(AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total) {
DPRINTLN(DBG_VERBOSE, "onApiPostBody");
DynamicJsonDocument json(200);
DynamicJsonDocument json(800);
AsyncJsonResponse* response = new AsyncJsonResponse(false, 200);
JsonObject root = response->getRoot();

Expand Down Expand Up @@ -708,8 +708,35 @@ class RestApi {
mApp->setTimestamp(0); // 0: update ntp flag
else if(F("serial_utc_offset") == jsonIn[F("cmd")])
mTimezoneOffset = jsonIn[F("val")];
else if(F("discovery_cfg") == jsonIn[F("cmd")]) {
else if(F("discovery_cfg") == jsonIn[F("cmd")])
mApp->setMqttDiscoveryFlag(); // for homeassistant
else if(F("save_iv") == jsonIn[F("cmd")]) {
Inverter<> *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*>());

for(uint8_t i = 0; i < 6; i++) {
iv->config->chMaxPwr[i] = jsonIn[F("ch")][i][F("pwr")];
iv->config->yieldCor[i] = jsonIn[F("ch")][i][F("yld")];
snprintf(iv->config->chName[i], MAX_NAME_LENGTH, "%s", jsonIn[F("ch")][i][F("name")].as<const char*>());
}

switch(iv->config->serial.b[4]) {
case 0x24:
case 0x22:
case 0x21: iv->type = INV_TYPE_1CH; iv->channels = 1; break;

case 0x44:
case 0x42:
case 0x41: iv->type = INV_TYPE_2CH; iv->channels = 2; break;

case 0x64:
case 0x62:
case 0x61: iv->type = INV_TYPE_4CH; iv->channels = 4; break;
default: break;
}
mApp->saveSettings(false); // without reboot
} else {
jsonOut[F("error")] = F("unknown cmd");
return false;
Expand Down
19 changes: 15 additions & 4 deletions src/web/html/api.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/**
* SVG ICONS
*/
/* SVG ICONS - https://icons.getbootstrap.com */

iconWifi1 = [
"M11.046 10.454c.226-.226.185-.605-.1-.75A6.473 6.473 0 0 0 8 9c-1.06 0-2.062.254-2.946.704-.285.145-.326.524-.1.75l.015.015c.16.16.407.19.611.09A5.478 5.478 0 0 1 8 10c.868 0 1.69.201 2.42.56.203.1.45.07.611-.091l.015-.015zM9.06 12.44c.196-.196.198-.52-.04-.66A1.99 1.99 0 0 0 8 11.5a1.99 1.99 0 0 0-1.02.28c-.238.14-.236.464-.04.66l.706.706a.5.5 0 0 0 .707 0l.708-.707z"
Expand Down Expand Up @@ -34,6 +32,15 @@ iconSuccessFull = [
"M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zm-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z"
];

iconGear = [
"M9.405 1.05c-.413-1.4-2.397-1.4-2.81 0l-.1.34a1.464 1.464 0 0 1-2.105.872l-.31-.17c-1.283-.698-2.686.705-1.987 1.987l.169.311c.446.82.023 1.841-.872 2.105l-.34.1c-1.4.413-1.4 2.397 0 2.81l.34.1a1.464 1.464 0 0 1 .872 2.105l-.17.31c-.698 1.283.705 2.686 1.987 1.987l.311-.169a1.464 1.464 0 0 1 2.105.872l.1.34c.413 1.4 2.397 1.4 2.81 0l.1-.34a1.464 1.464 0 0 1 2.105-.872l.31.17c1.283.698 2.686-.705 1.987-1.987l-.169-.311a1.464 1.464 0 0 1 .872-2.105l.34-.1c1.4-.413 1.4-2.397 0-2.81l-.34-.1a1.464 1.464 0 0 1-.872-2.105l.17-.31c.698-1.283-.705-2.686-1.987-1.987l-.311.169a1.464 1.464 0 0 1-2.105-.872l-.1-.34zM8 10.93a2.929 2.929 0 1 1 0-5.86 2.929 2.929 0 0 1 0 5.858z"
];

iconDel = [
"M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z",
"M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"
];

/**
* GENERIC FUNCTIONS
*/
Expand Down Expand Up @@ -119,7 +126,7 @@ function parseRssi(obj) {
icon = iconWifi1;
else if(obj["wifi_rssi"] <= -70)
icon = iconWifi2;
document.getElementById("wifiicon").replaceChildren(svg(icon, 32, 32, "wifi", obj["wifi_rssi"]));
document.getElementById("wifiicon").replaceChildren(svg(icon, 32, 32, "icon-fg", obj["wifi_rssi"]));
}

function toIsoDateStr(d) {
Expand Down Expand Up @@ -181,6 +188,10 @@ function tr(val1, val2) {
]);
}

function badge(success, text, second="error") {
return ml("span", {class: "badge badge-" + ((success) ? "success" : second)}, text);
}

function des(val) {
e = document.createElement('p');
e.classList.add("subdes");
Expand Down
2 changes: 1 addition & 1 deletion src/web/html/colorDark.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
--secondary: #0072c8;
--nav-active: #555;
--footer-bg: #282828;
--modal-bg: #666;
--modal-bg: #282828;

--invalid-bg: #400;

Expand Down
Loading

0 comments on commit 975f692

Please sign in to comment.