Skip to content

Commit

Permalink
0.7.24
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
lumapu committed Aug 5, 2023
1 parent b586d7e commit 85dae38
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 23 deletions.
7 changes: 7 additions & 0 deletions src/CHANGES.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ void app::setup() {

mPubSerial.setup(mConfig, &mSys, &mTimestamp);

mImprov.setup(this, mConfig->sys.deviceName, mVersion);
//mImprov.setup(this, mConfig->sys.deviceName, mVersion);

regularTickers();
}

//-----------------------------------------------------------------------------
void app::loop(void) {
mInnerLoopCb();
mImprov.tickSerial();
//mImprov.tickSerial();
}

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -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");
}

//-----------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions src/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions 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 7
#define VERSION_PATCH 23
#define VERSION_PATCH 24

//-------------------------------------
typedef struct {
Expand Down Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions src/publisher/pubMqtt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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;

Expand All @@ -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);
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/web/html/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
12 changes: 6 additions & 6 deletions src/web/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,12 @@ <h3>Support this project:</h3>
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"]) {
Expand All @@ -131,16 +133,14 @@ <h3>Support this project:</h3>
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";
}

Expand Down
2 changes: 1 addition & 1 deletion src/web/html/setup.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit 85dae38

Please sign in to comment.