Skip to content

Commit

Permalink
0.8.4
Browse files Browse the repository at this point in the history
* changed MqTT alarm topic, removed retained flag #1212
* reduce last_success MQTT messages (#1124)
  • Loading branch information
lumapu committed Nov 10, 2023
1 parent 4e9a09f commit c98d35d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 22 deletions.
4 changes: 4 additions & 0 deletions src/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Development Changes

## 0.8.4 - 2023-11-10
* changed MqTT alarm topic, removed retained flag #1212
* reduce last_success MQTT messages (#1124)

## 0.8.3 - 2023-11-09
* fix yield day reset during day #848
* add total AC Max Power to WebUI
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 3
#define VERSION_PATCH 4

//-------------------------------------
typedef struct {
Expand Down
26 changes: 9 additions & 17 deletions src/publisher/pubMqtt.h
Original file line number Diff line number Diff line change
Expand Up @@ -516,25 +516,17 @@ class PubMqtt {

snprintf(mSubTopic, 32 + MAX_NAME_LENGTH, "%s/alarm/cnt", iv->config->name);
snprintf(mVal, 40, "%d", iv->alarmCnt);
publish(mSubTopic, mVal, true);
publish(mSubTopic, mVal, false);

for(uint8_t j = 0; j < 10; j++) {
if(0 != iv->lastAlarm[j].code) {
snprintf(mSubTopic, 32 + MAX_NAME_LENGTH, "%s/alarm/%d/code", iv->config->name, j);
snprintf(mVal, 40, "%d", iv->lastAlarm[j].code);
publish(mSubTopic, mVal, true);

snprintf(mSubTopic, 32 + MAX_NAME_LENGTH, "%s/alarm/%d/str", iv->config->name, j);
snprintf(mVal, 40, "%s", iv->getAlarmStr(iv->lastAlarm[j].code).c_str());
publish(mSubTopic, mVal, true);

snprintf(mSubTopic, 32 + MAX_NAME_LENGTH, "%s/alarm/%d/start", iv->config->name, j);
snprintf(mVal, 40, "%d", iv->lastAlarm[j].start + lastMidnight);
publish(mSubTopic, mVal, true);

snprintf(mSubTopic, 32 + MAX_NAME_LENGTH, "%s/alarm/%d/end", iv->config->name, j);
snprintf(mVal, 40, "%d", iv->lastAlarm[j].end + lastMidnight);
publish(mSubTopic, mVal, true);
snprintf(mSubTopic, 32 + MAX_NAME_LENGTH, "%s/alarm/%d", iv->config->name, j);
snprintf(mVal, 100, "{\"code\":%d,\"str\":\"%s\",\"start\":%d,\"end\":%d}",
iv->lastAlarm[j].code,
iv->getAlarmStr(iv->lastAlarm[j].code).c_str(),
iv->lastAlarm[j].start + lastMidnight,
iv->lastAlarm[j].end + lastMidnight);
publish(mSubTopic, mVal, false);
yield();
}
}
Expand Down Expand Up @@ -613,7 +605,7 @@ class PubMqtt {
// global buffer for mqtt topic. Used when publishing mqtt messages.
char mTopic[MQTT_TOPIC_LEN + 32 + MAX_NAME_LENGTH + 1];
char mSubTopic[32 + MAX_NAME_LENGTH + 1];
char mVal[40];
char mVal[100];
discovery_t mDiscovery;
};

Expand Down
5 changes: 1 addition & 4 deletions src/publisher/pubMqttIvData.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class PubMqttIvData {
mZeroValues = false;

memset(mIvLastRTRpub, 0, MAX_NUM_INVERTERS * sizeof(uint32_t));
memset(mIvLastPublish, 0, MAX_NUM_INVERTERS * sizeof(uint32_t));
mRTRDataHasBeenSent = false;

mTable[IDLE] = &PubMqttIvData::stateIdle;
Expand Down Expand Up @@ -103,7 +102,7 @@ class PubMqttIvData {
mPos = 0;
if(found) {
record_t<> *rec = mIv->getRecordStruct(mCmd);
if((mIv->getLastTs(rec) != mIvLastPublish[mIv->id]) && mIv->getLastTs(rec) != 0 ) { //workaround for startup. Suspect, mCmd might cause to much messages....
if((RealTimeRunData_Debug == mCmd) && mIv->getLastTs(rec) != 0 ) { //workaround for startup. Suspect, mCmd might cause to much messages....
snprintf(mSubTopic, 32 + MAX_NAME_LENGTH, "%s/last_success", mIv->config->name);
snprintf(mVal, 40, "%d", mIv->getLastTs(rec));
mPublish(mSubTopic, mVal, true, QOS_0);
Expand Down Expand Up @@ -134,7 +133,6 @@ class PubMqttIvData {
pubData &= (lastTs != mIvLastRTRpub[mIv->id]);

if (pubData) {
mIvLastPublish[mIv->id] = lastTs;
if(mPos < rec->length) {
bool retained = false;
if (mCmd == RealTimeRunData_Debug) {
Expand Down Expand Up @@ -241,7 +239,6 @@ class PubMqttIvData {
Inverter<> *mIv, *mIvSend;
uint8_t mPos;
uint32_t mIvLastRTRpub[MAX_NUM_INVERTERS];
uint32_t mIvLastPublish[MAX_NUM_INVERTERS];
bool mRTRDataHasBeenSent;

char mSubTopic[32 + MAX_NAME_LENGTH + 1];
Expand Down

0 comments on commit c98d35d

Please sign in to comment.