Browse Source

0.7.24

* merge PR #1069 make MqTT client ID configurable
* fix #1016, general MqTT status depending on inverter state machine
* changed icon for fully available inverter to a filled check mark #1070
* fixed `last_success` update with MqTT #1068
* removed `improv` esp-web-installer script, because it is not fully functional at this time
pull/1093/head
lumapu 2 years ago
parent
commit
85dae3805f
  1. 7
      src/CHANGES.md
  2. 6
      src/app.cpp
  3. 4
      src/app.h
  4. 4
      src/defines.h
  5. 18
      src/publisher/pubMqtt.h
  6. 4
      src/web/html/api.js
  7. 12
      src/web/html/index.html
  8. 2
      src/web/html/setup.html

7
src/CHANGES.md

@ -1,5 +1,12 @@
# Development Changes
## 0.7.24 - 2023-08-05
* merge PR #1069 make MqTT client ID configurable
* fix #1016, general MqTT status depending on inverter state machine
* changed icon for fully available inverter to a filled check mark #1070
* fixed `last_success` update with MqTT #1068
* removed `improv` esp-web-installer script, because it is not fully functional at this time
## 0.7.23 - 2023-08-04
* merge PR #1056, visualization html
* update MqTT library to 1.4.4

6
src/app.cpp

@ -97,7 +97,7 @@ void app::setup() {
mPubSerial.setup(mConfig, &mSys, &mTimestamp);
mImprov.setup(this, mConfig->sys.deviceName, mVersion);
//mImprov.setup(this, mConfig->sys.deviceName, mVersion);
regularTickers();
}
@ -105,7 +105,7 @@ void app::setup() {
//-----------------------------------------------------------------------------
void app::loop(void) {
mInnerLoopCb();
mImprov.tickSerial();
//mImprov.tickSerial();
}
//-----------------------------------------------------------------------------
@ -214,7 +214,7 @@ void app::regularTickers(void) {
everySec(std::bind(&DisplayType::tickerSecond, &mDisplay), "disp");
every(std::bind(&PubSerialType::tick, &mPubSerial), mConfig->serial.interval, "uart");
//everySec(std::bind(&Improv::tickSerial, &mImprov), "impro");
// every([this]() {mPayload.simulation();}, 15, "simul");
//every([this]() {mPayload.simulation();}, 15, "simul");
}
//-----------------------------------------------------------------------------

4
src/app.h

@ -24,7 +24,7 @@
#include "utils/crc.h"
#include "utils/dbg.h"
#include "utils/scheduler.h"
#include "utils/improv.h"
//#include "utils/improv.h"
#include "web/RestApi.h"
#include "web/web.h"
#include "wifi/ahoywifi.h"
@ -304,7 +304,7 @@ class app : public IApp, public ah::Scheduler {
PayloadType mPayload;
MiPayloadType mMiPayload;
PubSerialType mPubSerial;
Improv mImprov;
//Improv mImprov;
#ifdef ESP32
CmtRadioType mCmtRadio;
HmsPayloadType mHmsPayload;

4
src/defines.h

@ -13,7 +13,7 @@
//-------------------------------------
#define VERSION_MAJOR 0
#define VERSION_MINOR 7
#define VERSION_PATCH 23
#define VERSION_PATCH 24
//-------------------------------------
typedef struct {
@ -85,7 +85,7 @@ enum {MQTT_STATUS_OFFLINE = 0, MQTT_STATUS_PARTIAL, MQTT_STATUS_ONLINE};
#define NTP_ADDR_LEN 32 // DNS Name
#define MQTT_ADDR_LEN 64 // DNS Name
#define MQTT_CLIENTID_LEN 65
#define MQTT_CLIENTID_LEN 22 // number of chars is limited to 23 up to v3.1 of MQTT
#define MQTT_USER_LEN 65 // there is another byte necessary for \0
#define MQTT_PWD_LEN 65
#define MQTT_TOPIC_LEN 65

18
src/publisher/pubMqtt.h

@ -76,11 +76,10 @@ class PubMqtt {
if((strlen(mCfgMqtt->user) > 0) && (strlen(mCfgMqtt->pwd) > 0))
mClient.setCredentials(mCfgMqtt->user, mCfgMqtt->pwd);
if(strlen(mCfgMqtt->clientId) > 0)
{
snprintf(mClientId, 24, "%s-", mCfgMqtt->clientId);
if(strlen(mCfgMqtt->clientId) > 0) {
snprintf(mClientId, 23, "%s-", mCfgMqtt->clientId);
mClient.setClientId(mCfgMqtt->clientId);
}else{
} else{
snprintf(mClientId, 24, "%s-", mDevName);
uint8_t pos = strlen(mClientId);
mClientId[pos++] = WiFi.macAddress().substring( 9, 10).c_str()[0];
@ -485,8 +484,13 @@ class PubMqtt {
// inverter status
iv->isProducing(); // recalculate status
if (iv->isAvailable())
if (InverterStatus::OFF < iv->status) {
anyAvail = true;
snprintf(mSubTopic, 32 + MAX_NAME_LENGTH, "%s/last_success", iv->config->name);
snprintf(mVal, 40, "%d", iv->getLastTs(rec));
publish(mSubTopic, mVal, true);
}
else // inverter is enabled but not available
allAvail = false;
@ -501,10 +505,6 @@ class PubMqtt {
snprintf(mSubTopic, 32 + MAX_NAME_LENGTH, "%s/available", iv->config->name);
snprintf(mVal, 40, "%d", (uint8_t)iv->status);
publish(mSubTopic, mVal, true);
snprintf(mSubTopic, 32 + MAX_NAME_LENGTH, "%s/last_success", iv->config->name);
snprintf(mVal, 40, "%d", iv->getLastTs(rec));
publish(mSubTopic, mVal, true);
}
}

4
src/web/html/api.js

@ -30,6 +30,10 @@ iconSuccess = [
"M10.97 4.97a.235.235 0 0 0-.02.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-1.071-1.05z"
];
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"
];
/**
* GENERIC FUNCTIONS
*/

12
src/web/html/index.html

@ -119,10 +119,12 @@
function parseIv(obj) {
var p = div(["none"]);
for(var i of obj) {
var icon = iconWarn;
var cl = "icon-warn";
avail = "";
var icon = iconSuccess;
var cl = "icon-success";
var avail = "";
if(false == i["enabled"]) {
icon = iconWarn;
cl = "icon-warn";
avail = "disabled";
}
else if(false == i["is_avail"]) {
@ -131,16 +133,14 @@
avail = "not yet available";
}
else if(0 == i["ts_last_success"]) {
icon = iconSuccess;
avail = "available but no data was received until now";
}
else {
icon = iconSuccess;
avail = "available and is ";
if(false == i["is_producing"])
avail += "not ";
else
cl = "icon-success";
icon = iconSuccessFull;
avail += "producing";
}

2
src/web/html/setup.html

@ -251,7 +251,7 @@
</div>
<div class="row mb-3">
<div class="col-12 col-sm-3 my-2">Client Id (optional)</div>
<div class="col-12 col-sm-9"><input type="text" name="clientId"/></div>
<div class="col-12 col-sm-9"><input type="text" name="mqttClientId"/></div>
</div>
<div class="row mb-3">
<div class="col-12 col-sm-3 my-2">Username (optional)</div>

Loading…
Cancel
Save