Browse Source

0.8.4

* changed MqTT alarm topic, removed retained flag #1212
* reduce last_success MQTT messages (#1124)
pull/1225/head
lumapu 1 year ago
parent
commit
c98d35d7c4
  1. 4
      src/CHANGES.md
  2. 2
      src/defines.h
  3. 26
      src/publisher/pubMqtt.h
  4. 5
      src/publisher/pubMqttIvData.h

4
src/CHANGES.md

@ -1,5 +1,9 @@
# Development Changes # 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 ## 0.8.3 - 2023-11-09
* fix yield day reset during day #848 * fix yield day reset during day #848
* add total AC Max Power to WebUI * add total AC Max Power to WebUI

2
src/defines.h

@ -13,7 +13,7 @@
//------------------------------------- //-------------------------------------
#define VERSION_MAJOR 0 #define VERSION_MAJOR 0
#define VERSION_MINOR 8 #define VERSION_MINOR 8
#define VERSION_PATCH 3 #define VERSION_PATCH 4
//------------------------------------- //-------------------------------------
typedef struct { typedef struct {

26
src/publisher/pubMqtt.h

@ -516,25 +516,17 @@ class PubMqtt {
snprintf(mSubTopic, 32 + MAX_NAME_LENGTH, "%s/alarm/cnt", iv->config->name); snprintf(mSubTopic, 32 + MAX_NAME_LENGTH, "%s/alarm/cnt", iv->config->name);
snprintf(mVal, 40, "%d", iv->alarmCnt); snprintf(mVal, 40, "%d", iv->alarmCnt);
publish(mSubTopic, mVal, true); publish(mSubTopic, mVal, false);
for(uint8_t j = 0; j < 10; j++) { for(uint8_t j = 0; j < 10; j++) {
if(0 != iv->lastAlarm[j].code) { if(0 != iv->lastAlarm[j].code) {
snprintf(mSubTopic, 32 + MAX_NAME_LENGTH, "%s/alarm/%d/code", iv->config->name, j); snprintf(mSubTopic, 32 + MAX_NAME_LENGTH, "%s/alarm/%d", iv->config->name, j);
snprintf(mVal, 40, "%d", iv->lastAlarm[j].code); snprintf(mVal, 100, "{\"code\":%d,\"str\":\"%s\",\"start\":%d,\"end\":%d}",
publish(mSubTopic, mVal, true); iv->lastAlarm[j].code,
iv->getAlarmStr(iv->lastAlarm[j].code).c_str(),
snprintf(mSubTopic, 32 + MAX_NAME_LENGTH, "%s/alarm/%d/str", iv->config->name, j); iv->lastAlarm[j].start + lastMidnight,
snprintf(mVal, 40, "%s", iv->getAlarmStr(iv->lastAlarm[j].code).c_str()); iv->lastAlarm[j].end + lastMidnight);
publish(mSubTopic, mVal, true); publish(mSubTopic, mVal, false);
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);
yield(); yield();
} }
} }
@ -613,7 +605,7 @@ class PubMqtt {
// global buffer for mqtt topic. Used when publishing mqtt messages. // global buffer for mqtt topic. Used when publishing mqtt messages.
char mTopic[MQTT_TOPIC_LEN + 32 + MAX_NAME_LENGTH + 1]; char mTopic[MQTT_TOPIC_LEN + 32 + MAX_NAME_LENGTH + 1];
char mSubTopic[32 + MAX_NAME_LENGTH + 1]; char mSubTopic[32 + MAX_NAME_LENGTH + 1];
char mVal[40]; char mVal[100];
discovery_t mDiscovery; discovery_t mDiscovery;
}; };

5
src/publisher/pubMqttIvData.h

@ -29,7 +29,6 @@ class PubMqttIvData {
mZeroValues = false; mZeroValues = false;
memset(mIvLastRTRpub, 0, MAX_NUM_INVERTERS * sizeof(uint32_t)); memset(mIvLastRTRpub, 0, MAX_NUM_INVERTERS * sizeof(uint32_t));
memset(mIvLastPublish, 0, MAX_NUM_INVERTERS * sizeof(uint32_t));
mRTRDataHasBeenSent = false; mRTRDataHasBeenSent = false;
mTable[IDLE] = &PubMqttIvData::stateIdle; mTable[IDLE] = &PubMqttIvData::stateIdle;
@ -103,7 +102,7 @@ class PubMqttIvData {
mPos = 0; mPos = 0;
if(found) { if(found) {
record_t<> *rec = mIv->getRecordStruct(mCmd); 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(mSubTopic, 32 + MAX_NAME_LENGTH, "%s/last_success", mIv->config->name);
snprintf(mVal, 40, "%d", mIv->getLastTs(rec)); snprintf(mVal, 40, "%d", mIv->getLastTs(rec));
mPublish(mSubTopic, mVal, true, QOS_0); mPublish(mSubTopic, mVal, true, QOS_0);
@ -134,7 +133,6 @@ class PubMqttIvData {
pubData &= (lastTs != mIvLastRTRpub[mIv->id]); pubData &= (lastTs != mIvLastRTRpub[mIv->id]);
if (pubData) { if (pubData) {
mIvLastPublish[mIv->id] = lastTs;
if(mPos < rec->length) { if(mPos < rec->length) {
bool retained = false; bool retained = false;
if (mCmd == RealTimeRunData_Debug) { if (mCmd == RealTimeRunData_Debug) {
@ -241,7 +239,6 @@ class PubMqttIvData {
Inverter<> *mIv, *mIvSend; Inverter<> *mIv, *mIvSend;
uint8_t mPos; uint8_t mPos;
uint32_t mIvLastRTRpub[MAX_NUM_INVERTERS]; uint32_t mIvLastRTRpub[MAX_NUM_INVERTERS];
uint32_t mIvLastPublish[MAX_NUM_INVERTERS];
bool mRTRDataHasBeenSent; bool mRTRDataHasBeenSent;
char mSubTopic[32 + MAX_NAME_LENGTH + 1]; char mSubTopic[32 + MAX_NAME_LENGTH + 1];

Loading…
Cancel
Save