mirror of
https://github.com/lumapu/ahoy.git
synced 2025-07-29 22:27:13 +02:00
fix MQTT avail status update: it was sent as often as processPayload was called (many times a second)
This commit is contained in:
parent
201af3a315
commit
1d385b1d60
1 changed files with 17 additions and 13 deletions
|
@ -170,6 +170,23 @@ void app::loop(void) {
|
||||||
|
|
||||||
mMqtt.sendMsg("uptime", val);
|
mMqtt.sendMsg("uptime", val);
|
||||||
|
|
||||||
|
for(uint8_t id = 0; id < mSys->getNumInverters(); id++) {
|
||||||
|
Inverter<> *iv = mSys->getInverterByPos(id);
|
||||||
|
if(NULL != iv) {
|
||||||
|
record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug);
|
||||||
|
char topic[32 + MAX_NAME_LENGTH], val[32];
|
||||||
|
if (!iv->isAvailable(mUtcTimestamp, rec) && !iv->isProducing(mUtcTimestamp, rec)){
|
||||||
|
snprintf(topic, 32 + MAX_NAME_LENGTH, "%s/available_text", iv->name);
|
||||||
|
snprintf(val, 32, DEF_MQTT_IV_MESSAGE_NOT_AVAIL_AND_NOT_PRODUCED);
|
||||||
|
mMqtt.sendMsg(topic, val);
|
||||||
|
snprintf(topic, 32 + MAX_NAME_LENGTH, "%s/available", iv->name);
|
||||||
|
snprintf(val, 32, "0");
|
||||||
|
mMqtt.sendMsg(topic, val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef __MQTT_TEST__
|
#ifdef __MQTT_TEST__
|
||||||
// für einfacheren Test mit MQTT, den MQTT abschnitt in 10 Sekunden wieder ausführen
|
// für einfacheren Test mit MQTT, den MQTT abschnitt in 10 Sekunden wieder ausführen
|
||||||
mMqttTicker = mMqttInterval -10;
|
mMqttTicker = mMqttInterval -10;
|
||||||
|
@ -480,19 +497,6 @@ void app::processPayload(bool retransmit) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mMqttActive) {
|
|
||||||
record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug);
|
|
||||||
char topic[32 + MAX_NAME_LENGTH], val[32];
|
|
||||||
if (!iv->isAvailable(mUtcTimestamp, rec) && !iv->isProducing(mUtcTimestamp, rec)){
|
|
||||||
snprintf(topic, 32 + MAX_NAME_LENGTH, "%s/available_text", iv->name);
|
|
||||||
snprintf(val, 32, DEF_MQTT_IV_MESSAGE_NOT_AVAIL_AND_NOT_PRODUCED);
|
|
||||||
mMqtt.sendMsg(topic, val);
|
|
||||||
snprintf(topic, 32 + MAX_NAME_LENGTH, "%s/available", iv->name);
|
|
||||||
snprintf(val, 32, "0");
|
|
||||||
mMqtt.sendMsg(topic, val);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
yield();
|
yield();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue